++ColinHorne on a very respectable first Japh!

Here are a few tips for "golfing" it down, should you desire to make it even more terse, while still preserving the important elements:

  1. Convert 'shift' to 'pop' wherever @_ contains a single argument.
  2. Get rid of the extra "{ }" around the main program, and get rid of extra "( )" wherever you can.
  3. Change "long" variable names like "count" and "buf" to single chars like "c" and "b".  (You can even get really obtuse and use variables like "$," and "$;" if you want)
  4. Get rid of 'my'.  You're not using strict anyway, so change all your variables to globals (it's not production code after all!)   Use a different name if there's a variable name conflict.  Then, you may have to assign to 0, but you can even save space there, with "$b=$c=0;" instead of "$b=0;$c=0;".  Or, if you're willing to forego warnings, you can even avoid the assignment, as $b and $c default to zero.
  5. Changing for(...){...} to map{...}... saves a few characters.  It has the added benefit that it forms an array, so you can actually get rid of all occurrences of @r!
  6. You have a string concatenation which seems unnecessary, and saves 3 characters ('"."')
  7. You can change "$b=(($b<<1)|($_?1:0))&255" to "$b=255&$b<<1|($_?1:0)" to save 4 chars.
  8. Changing "print chr($b)unless(++$c%8)" to "++$c%8or print chr$b" saves 7 chars.
  9. If you change "(reverse(0..7))" to "(-7..0)", and change the sign of $_ where it's used "2**-$_", it'll have the same effect, but obviates the need for "reverse". (You need two extra '-', but you also save a pair of parens "(...)").
  10. You were already careful not to have the last statement in each subroutine end with ';', and you can apply that to the last line of the program as well.
  11. Finally, prefer $/ over "\n", and you save a couple of chars.

And here is the final result:

#!/usr/bin/perl @k=split//,'colin@colinhorne.co.uk'; @p=sub{$_=pop;map{sub{$_=pop;map{chr(eval"0b$_")}/.{8}/g}->(sprintf('% +032b',eval "0x$_"))}split/,/;}->("291a1f1d,4e210d00,18010b1a,4f220b17,4243274f,16 +080a1e"); sub d{$b=255&$b<<1|($_?1:0);++$c%8or print chr$b}sub{$f=pop;map{for$a( +map{2**-$ _}(-7..0)){local$_=(ord($k[$_%$#k])^ord($p[$_]))&$a;&$f}}0..$#p}->(\&d +);print$/

s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

In reply to Re: My first JAPH by liverpole
in thread My first JAPH by ColinHorne

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.