my $i = 0; my %occult = map { $_ => ($i++ %9) + 1 } ('A' .. 'Z'); my $news = 'FOX'; print join( '', map $occult{$_}, split '', $news ) . $/;