my %table = ( A => 123, b => 200, ... ); my $sum = 0; $sum += $table{$_} for split //, $word;