Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Just to say hello

3 views
Skip to first unread message

Sandro CAZZANIGA

unread,
Nov 9, 2011, 12:02:54 PM11/9/11
to f...@perl.org
Hi,

I'm new to this list and I'll send some JAPH's and little code, and I will
happy to read yours. :)

Cheers.

Sandro CAZZANIGA

unread,
Nov 9, 2011, 12:26:03 PM11/9/11
to Bennett Todd, f...@perl.org
2011/11/9 Bennett Todd <b...@rahul.net>

> I think this list may have fallen into disuse. I don't have any fresh
> juicy bits to share, I'm sorry. I hope you inspire some contributions to
> re-kindle the list.
>
> The only cool perl trick I recall at this instant is the Schwartzian
> Transform; if you haven't run across it and it doesn't Google right up, let
> me know and I'll be glad to compose a review of it. I think the canonical
> explanation of it is in Tom Christiansen's Far More Than Everything You
> Ever Wanted To Know (FMTEYWTK) series.
>

we can relauch this list with a lot of JAPH's, may be.... :)

Philippe Bruhat (BooK)

unread,
Nov 9, 2011, 12:12:17 PM11/9/11
to f...@perl.org
On Wed, Nov 09, 2011 at 06:02:54PM +0100, Sandro CAZZANIGA wrote:
>
> I'm new to this list and I'll send some JAPH's and little code, and I
> will happy to read yours. :)
>

Well, the latest mail I received on this list was from Fri, 4 Sep 2009
16:38:22 -0500, so you might need a little patience if you want to read
some code. Better write it!

--
Philippe Bruhat (BooK)

Where there are hearts of gold, there is no need for bars of steel.
(Moral from Groo The Wanderer #103 (Epic))

Andy...@wiwb.uscourts.gov

unread,
Nov 9, 2011, 12:41:38 PM11/9/11
to Sandro CAZZANIGA, Bennett Todd, f...@perl.org
Here's a JAPH and explanation from the Perl-Win32-Users mailing list -
this has some quirks. On win7, I got back "steal Porch Junk" on some
versions of perl you get a newline, on some you get a syntax error but the
explanation is great!:

$_=q;steal Porch Junk;;split//;$_=q=cd0153e71;
s/56s/45;39fs/=;y;\;s/;a28s/;;;s;$/;;;s((.))/;
q.$_[..$..$_[10].$_[2].q.x..q.($1)]./gee/print

> That's one convoluted JAPH!

Thanks.

> I like to pick through admirable JAPH's like this in an
> attempt to learn more Perl idiosyncrasies [...]
> Anyone care to explain what's going on?

How about I tell you how I created it, which I think makes it easier to
see
what's going on.

Every JAPH starts out with a small idea on some transormation of the
phrase
"Just Another Perl Hacker". I noticed there are repeated letters in that
phrase, so I decided to collapse the phrase down to just the unique
letters
and then rebuild the phrase by indexing them.

# Reduce to unique characters
$japh = 'Just another Perl hacker';
$letter{$_}++ foreach split//, $japh;
print join "", sort keys %letter;

So now I'm working with the string " JPacehklnorstu". But that string
doesn't have to be in any particular order, so it's off to the Internet
Anagram Server (http://www.wordsmith.org/anagram/) to make things
interesting. There are lots of funny results, and I ended up making a few
different versions of the JAPH with them. The one you saw was "steal Porch
Junk".

So now, I just create a list of indices to extract the proper phrase back
out. I could simply use the following:

@indices = (12,13,0,1,5,3,14,7,1,10,2,8,5,6,2,8,4,5,10,3,9,15,2,8);

But that would be boring. And take up quite a bit of space. I noticed that
the range is 0..15 or one nybble (half a byte). I could pack all 24
indices
in just 12 bytes! I decided to represent the bytes as hex characters:

# pack 'em into bytes.
while (@indices) {
$byte = (shift(@indices)<<4)|shift(@indices);
printf('%x',$byte);
}

So now I'm working with the string "cd0153e71a28562845a39f28". To extract
the indices, I just have to use hex() on each character in that string.

So now, let's put together a first cut at the JAPH, using the techniques
above:

$_="steal Porch Junk"; @_=split //; # put the letters in @_
$_="cd0153e71a28562845a39f28"; # put the indices in $_
s/(.)/$_[hex($1)]/ge; # replace each index with its
letter
print; # print it out

Now the fun part... let's obfuscate it a bit. Adding another "e" to the
regex is low-hanging fruit. We just assemble the '$_[hex($1)]' part via
concatenated strings:

s/(.)/'$_[' . 'hex' . '($1)]'/gee;

I don't like the quotes. Too obvious. Lets change them to q() but use '.'
instead of the parens (anyone who gets confused by this needs to read
perldoc perlop):

s/(.)/q.$_[. . q.hex. . q.($1)]./gee;

Looking better, but that 'hex' stands out like a sore thumb. Noticing that
the "h" and "e" are in our letter list (@_), I decide to assemble the
'hex',
which is just a string at this point, from those letters ("h" = $_[10],
"e"
= $_[2]), leaving the 'x':

s/(.)/q.$_[. . $_[10] . $_[2] . q.x. . q.($1)]./gee

Better. Now let's get rid of the quotes from the rest of the JAPH too,
using
q.. and q==

$_=q;steal Porch Junk;;split //;
$_=q=cd0153e71a28562845a39f28=;
s/(.)/q.$_[. . $_[10] . $_[2] . q.x. . q.($1)]./gee;
print;

Now let's break up that hex string in the second line. I see it has three
"28"'s, so we can do a substitution. What should we replace it with? The
string "s/" is about as diabolical as any. ";q" would have been a good one
too. I chose the former. In our y// (or y;; to be tricky) lets also
replace
the "a"'s with ";". We'll also insert a newline, which we take back out
with
a s/\n//;

$_=q;steal Porch Junk;;split//;$_=q=cd0153e71;
s/56s/45;39fs/=;
y;\;s/;a28;;
s;\n;;;
s/(.)/q.$_[. . $_[10] . $_[2] . q.x. . q.($1)]./gee;
print;

Now let's smash it up a bit:

$_=q;steal Porch Junk;;split//;$_=q=cd0153e71;
s/56s/45;39fs/=;y;\;s/;a28;;s;\n;;;
s/(.)/q.$_[..$_[10].$_[2].q.x..q.($1)]./gee;print;

Looking kinda JAPHy now, isn't it? There's a few more things we can do.
The
y operator can take extra chars at the end without consequence. We'll add
another decoy 's/'. In the first substitution, let's replace '\n' with
'$/'.

$_=q;steal Porch Junk;;split//;$_=q=cd0153e71;
s/56s/45;39fs/=;y;\;s/;a28s/;;s;$/;;;
s((.))/q.$_[..$_[10].$_[2].q.x..q.($1)]./gee;print;

Now, let's work on the substitution again. We can split it between lines,
and change s/// to s()//. Also we can change the ';' before print to a
'/',
which is interpreted as a divide, but will still evaluate the 'print' with
a
warning under -w which we don't care about.

$_=q;steal Porch Junk;;split//;$_=q=cd0153e71;
s/56s/45;39fs/=;y;\;s/;a28s/;;s;$/;;;s((.))/
q.$_[..$_[10].$_[2].q.x..q.($1)]./gee/print;

More stuff: Let's insert some ';' where they won't make a difference, and
remove one from the end. Then I want to pad the last line by 2 chars
because
I like to make the lines equal length. We can add $. (which contains
nothing
outside a loop) to the substitution string.

$_=q;steal Porch Junk;;split//;$_=q=cd0153e71;
s/56s/45;39fs/=;y;\;s/;a28s/;;;s;$/;;;s((.))/;
q.$_[.$..$_[10].$_[2].q.x..q.($1)]./gee/print;

More can always be done, but at this point it looks good enough for me.

Hope you found this interesting.


--
Mark Thomas Thoma...@bls.gov
Internet Systems Architect DigitalNet, Inc.

$_=q;steal Porch Junk;;split//;$_=q=cd0153e71;
s/56s/45;39fs/=;y;\;s/;a28s/;;;s;$/;;;s((.))/;
q.$_[..$..$_[10].$_[2].q.x..q.($1)]./gee/print

_______________________________________________

----------------------
Andy Bach
Systems Mangler
Internet: andy...@wiwb.uscourts.gov
Voice: (608) 261-5738, Cell: (608) 658-1890

We are what we pretend to be, so we must be careful about what we
pretend to be.
Kurt Vonnegut

Brian Fraser

unread,
Nov 9, 2011, 1:33:43 PM11/9/11
to Sandro CAZZANIGA, f...@perl.org
Huh, I didn't even know I was on this mailing list.
Cool.

This inspired me to write my first JAPH ever. Nothing spectacular, but
requires perl 5.14, because of shenanigans. And I cheat for the 'k'.

perl -wE 'BEGIN {$SIG{__WARN__}=sub{$_.=substr(shift,0,1)}} J::J(1); map
{},*_=
undef,seekdir(_,0),telldir(_),accept(_,0),$SIG{Derpy}=1,{_=>},tell(_),eval"s///sand
/1/; if (1) {} elseif (1) {};", readdir(_), printf(_), eval { next },
readdir(_), listen(_,0), eval"keys(_)", accept(_,0); $x = closedir(_); warn
"k"; {sub { next }->()} $x = readline(_); sub J::J (\%) {}; say map "\u\L$_
", m!(?x)\U@{[map "(\\x{$_})",4,7,4,6]}!g'

Ethridge, David

unread,
Nov 9, 2011, 12:35:19 PM11/9/11
to f...@perl.org, Sandro CAZZANIGA
I am a lurker who always aspired to the coding brilliance exhibited on
this list. I piddle in perl from time to time but am still much the
novice. I would love to see life breathed back into the list too. Any
new perl poems to share?

Fond of fwp,
David Ethridge

Bill Jones

unread,
Nov 10, 2011, 5:52:58 PM11/10/11
to f...@perl.org
I am in shock; this list is still alive? Good to know :)

Sandro CAZZANIGA

unread,
Nov 11, 2011, 4:06:25 AM11/11/11
to Bill Jones, f...@perl.org
2011/11/10 Bill Jones <chasecreek....@gmail.com>

> I am in shock; this list is still alive? Good to know :)
>


Yes, we have to make it alive for years!! :)
0 new messages