in reply to More Efficient Subroutine

Breaking this kind of encryption is downright trivial. People who know what they are doing can do it by hand in a matter of minutes based on character frequency. If you want encryption, I strongly recommend looking for an appropriate module.

But it looks like you knew that. Even without formatting (the <code> tag exists for a reason) it looks like you are trying to do ROT13. The problem you have is that you have a lot of this or this or this or... logic which has to be scanned on each character. It is far faster to arrange to have a hash that contains the answer and do a lookup. So the key logic would be:

my $encrypted = join '', map {exists $trans{$_} ? $trans{$_} : $_} spl +it //, $orig;
Of course the tr function gives an even more efficient solution in this case.

But the general performance note is that any time you can convert scanning logic (scanning a string, array, file, whatever) to a hash lookup, you moved to a more efficient algorithm and if the thing scanned was long should see significant performance improvments.