in reply to Re^3: I put the J in JAPH
in thread I put the J in JAPH
I like it a lot, but it seems very clear what is happening... you are explicitly mapping each of the words to a function. With the help of indirect objects and AUTOLOAD, you self-map a bit, muddy the waters, and avoid repeating yourself:
use warnings; @a=(sub{$O=$_[0]},sub{$O=$_[0].$O},sub{$O.=$/;shift},sub{ ($_=$O)=~s~$_[1]~~;print});*{$_.q;::AUTOLOAD;}=sub{shift( @a)->(@_)}for(v74,112.117.116,116.104.101,82.65.80.72);#! I put the J in RAPH and remove the R
Some downsides/challenges: you have to spell out the objects (which I cheat with vstrings--), and I've lost my use strict; and I don't think that it can be massaged back in. Can anyone think of a way to grab package names as they autoviv?
Update: trimmed some fat.
Explanation for liverpole:
What is actually being called in this is as follows (in this order:
# de-munged a bit: *{$_."::AUTOLOAD"} = sub { shift(@a)->(@_); } for qw{ J put the RAPH };
For each required package I am creating an AUTOLOAD that simply calls the next sub in my action stack. In the case of RAPH::in() and J::the() the calling package is our payload. I had a mess of indirection in there before, but I've golfed it down.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: I put the J in JAPH
by liverpole (Monsignor) on Sep 19, 2005 at 14:21 UTC |