in reply to convert letters into a number
This is just an example, but it works...:
$string = "AFP254"; $number = 1; foreach('A'..'Z'){ $alpha_nums{$_} = $number; $number++; } + @string = split("", $string); $total = 0; foreach(@string){ if(/\S/ && !/\d/){ $_ = $alpha_nums{$_}; } $total = $_+$total; } print "$total\n";
|
|---|