You might want to try using "special" variables to make your life easier and/or more obfuscated. For example, don't use @d. Use @_ instead. This means you can write shift instead of shift(@d). You can use $/, the newline separator, instead of \n. Similar to @_, you could use $_ instead of $d which gets you tighter regular expressions. And lastly, instead of making your for loop work like C code (for ($n=1;$n < 21; $n++)), you might try something like for $n (1..@_). Note that @_ is forced into scalar context, which translates to the length, which is 20.

Here is what your code might turn into after these changes:
#!/usr/bin/perl @_=(255,60,252,195,24,195,195,195,24,255,252,255, 216,195,192,195,112,195,192,195);for $n(1..@_){ $_ .=' '.unpack("B8",pack("v",shift));unless($n%4) {s/0/ /g;print $_,$/;$_='';}}

Other thoughts include using the list nature of pack to simplify the for loop. Also, the numbers 255, 195, and 192 come up multiple times in the data block. You might want to start with a smaller data block and graft multiple copies of those numbers into it. It might result in smaller code.

-Ted

In reply to RE: my first try: japh by tedv
in thread my first try: japh by zzspectrez

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.