Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Alpha base-26 to base-10...

by pfaut (Priest)
on Jun 30, 2003 at 23:02 UTC ( #270357=note: print w/ replies, xml ) Need Help??


in reply to Alpha base-26 to base-10...

#!/usr/bin/perl -w use strict; sub convert26 { my $v = 0; $v = ($v * 26 + $_ - ord('a') + 1) for unpack("C*",shift); $v; } while (<DATA>) { chomp; print "$_: ",convert26($_),$/; } __DATA__ a z aa az ba zz aaa

Output:

a: 1 z: 26 aa: 27 az: 52 ba: 53 zz: 702 aaa: 703
90% of every Perl application is already written.
dragonchild


Comment on Re: Alpha base-26 to base-10...
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://270357]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2015-07-08 07:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (96 votes), past polls