my %map = ( ... ); $map{$_} = $_ for 0..9; my $numeric; for (split //, uc($word)) { $numeric .= $map{$_}; } say $numeric;