my %freq = ( a => 123, b => 200, c => 700, ... z => 800, ); my $sum = 0; for (split //, $word) { $sum += $freq{$_}; } print "Sum: $sum\n";