1 2 3 4 5 6 7 8 9 10 11 12 13
my @test = qw(A B Z AA AC BA ABC); sub SIZE_ALPHABET() { scalar (() = 'A'..'Z') } for my $test (@test) { my $num = 0; for my $idx (0..length($test) -1) { my $char = substr($test, -$idx-1, 1); $num += ((ord($char) - ord('A') + 1) * (SIZE_ALPHABET ** $idx)); } say "$test = $num"; }