"You all need to read the comments ..."

To be fair, you really could have made the "instructions" more clear, but i did take your suggestion and re-read your comments and came up with the following code:

#!/usr/bin/env perl use strict; use warnings; use Data::Dumper; use List::Util qw( shuffle ); my $str = shift || 'The impatient fox jumped over the lazy camel with +hubris.'; my( @codes, %encode ); my @base = ('a' .. 'z', 'A' .. 'Z', 0 .. 9); for my $i (@base) { push @codes, $i; for my $j (@base) { push @codes, "$i$j"; for my $k (@base) { push @codes, "$i$j$k"; } } } @codes = shuffle @codes; for (split /\s+/, $str) { $encode{$_} = shift @codes; } $str =~ s/([A-Za-z0-9.]+)/$encode{$1}/eg; print $str,$/; my %decodes = reverse %encode; $str =~ s/(\w+)/$decodes{$1}/eg; print $str,$/;
And yes, this is kind of cool. Why you didn't provide an end-to-end complete example is probably the root of your down-votes on the OP.

"It is obvious to any Perl developer worth his salt what the code is doing and what the purpose is."

Just remember, the more time you spend ensuring that your documentation is unambiguous, clear and complete the less time you'll spend defending your position, which essentially boils down to an inability to communicate effectively. Next time ... take the time to make your presentation more presentable -- in other words, implement the purpose as well.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to Re^3: Non-Formula based Text Encoding - with Compression by jeffa
in thread Non-Formula based Text Encoding - with Compression by locked_user erichansen1836

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.