in reply to Re: Converting "IV" from base 26
in thread Converting "IV" from base 26
You could also factor out the ord("A") + 1 part into a separate variable, but I think it's a little easier to read this way (and the cost of the extra calls to ord is probably negligible).sub v { my $sum = 0; for (split //, $_[0]) { $sum *= 26; $sum += ord($_) - ord("A") + 1; } return $sum; }
|
|---|