http://www.perlmonks.org?node_id=40751


in reply to Kiddie Codes

I might do something like this:
$letter = 'a'; @ct = qw{ 11 41 71 }; $forward{$letter} = [ @ct ]; ... # Build reverse hash foreach $letter (keys %forward) { foreach $ciphertext (@{$forward{$letter}}) { $reverse{$ciphertext} = $letter; } } print join(" ", @forward{split(//, "plaintext")}); print join("", @reverse{qw{ 19 59 71 75 77 63 13 66 33 }});