[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Letters to Numbers [Was - Re: [MacPerl] Hi there]



A 'clearer' explanation - if there is one...

$_ = "This converts Letters 2 Numbers.";
$_ =~ s/\G(\s*)(\S+\s*)/{
   foreach $chr ((split('',$2))) {
      print $chr . ' is ' . (ord(uc($chr)) - 64) . "\n";
   } }/ge;
print;


(OK, I'm going back into hibernation now...)

HTH,  -Sneex-  :]
- FCCJ * 501 W State St * Jacksonville, Fl 32202 * 904/632-3089 -

> I was thinking -
> 
> $_ = "This turns letters into numbers";
> 
> $_ =~ s/\G(\s*)(\S+\s*)/{
> foreach $chr ((split('',$2))) {
> print (ord(uc($chr)) - 64);
> } }/ge;
> print;
> 
> 
> I know this works, but maybe this is simpler ...
> $_ = 'abcdef';
> foreach $chr (split('',$_)) {
> print (ord(uc($chr)) - 64);
> }
> 
> 
> There are many characters that this will not work on
> Like these ... but you only mentioned Letters...


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe