http://www.perlmonks.org?node_id=908146


in reply to Pulling JAPH out of nowhere...

Hi,

That's a nice one. I like the fact that it uses pretty much all existing pattern elements. It should definitely be added to perlpacktut, its examples aren't unclear enough.

Unless you're making a motto to using nothing else than packs and unpacks, you could replace the 25 outermost packs by map pack.

Replies are listed 'Best First'.
Re^2: Pulling JAPH out of nowhere...
by ambrus (Abbot) on Jun 08, 2011 at 10:32 UTC

    All pattern elements? Does it use all the crazy and redundant ones as well? My favourites are

    $ perl -we 'print unpack "x*(a*\@0X)*(a*@)*", "hello\n";' o lo llo ello hello ello llo lo o $ perl -we 'print unpack(pack("(a*)*", unpack("(a*@[])*", "x./a")), " +J ust anotherr perl hacker\n");' Just another perl hacker $

    Update: see also Just another unpack hacker.

Re^2: Pulling JAPH out of nowhere...
by kejohm (Hermit) on Jun 05, 2011 at 01:00 UTC

    I was considering using map(), but I figured I should only use pack() and unpack() (I could also have used chr() in place of pack('C',...)).

    There were certain templates that I ignored for one reason or another. The 'P' and 'p' templates would probably only produce random data, and the 'w' template is only available on newer versions of Perl. Also, the 'q' and 'Q' only work on 64-bit Perl, and the 'X' template didn't really seem to make much sense in this context.