in reply to secret code, transliteration prob

You have an issue with the encoding : your $string will most likely contain repeated letters. i.e. letters occurring more than once.

This will cause problems when decoding, because multiple letters will be mapped to those repeated letters.

Here is (an inefficient, but functioning) way to avoid that when creating $string:

my $string = join '',map {splice(@chars,rand @chars,1)} 1..26;

        This is not an optical illusion, it just looks like one.