Aside from my failure to understand what value the output of this code offers, the quality of the code is very poor.

  1. use POD instead of single line comments for blocks of comments
  2. use strict and warnings (and declare your variables!)
  3. use Getopt::Long to allow your client to specify arguments you have instead hard coded or just use STDOUT
  4. don't use 3 arrays when 1 will suffice
  5. consider your solution is O(N^3) and that can be improved
  6. in fact ... there might be a mathematical formula that can derive these combinations in O(N) instead

In other words, something more like this:

#!/usr/bin/env perl use strict; use warnings; my @base = ( 'a'..'z', 'A'..'Z', 0..9 ); for my $i (@base) { print "$i\n"; for my $j (@base) { print "$i$j\n"; for my $k (@base) { print "$i$j$k\n"; } } } __END__ =head1 NAME non-forumla-based-text-encoder-with-compression.pl =head1 DESCRIPTION =over 4 =item * Create 242,234 unique codes, 1-3 characters in length, from the characters {a-zA-Z0-9}. =item * 62 (1 char codes) + 3844 (2 char codes) + 238,328 (3 char codes) = 242,234 unique codes. =item * (Somewhat like MIMEbase64 encoding, but my encoding is non-formula based.) =item * ... =back =cut
And then the client can redirect STDOUT to their own file of choice.

Now then ... i'd really like to see if someone can get this down to O(N). :)

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: 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.