in reply to Python dict to perl hash
Why use a hash when tr does the job so simply and efficiently?:
sub rot13{ my $text = shift; $text =~ tr[a-zA-Z][n-za-mN-ZA-M]; return $text };; $msg = 'The quick brown fox jumps over the lazy dog. And then runs awa +y.';; print rot13( $msg );; Gur dhvpx oebja sbk whzcf bire gur ynml qbt. Naq gura ehaf njnl. print rot13( rot13( $msg ) );; The quick brown fox jumps over the lazy dog. And then runs away.
|
|---|