Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: 59 /e

by iamcal (Friar)
on Jun 18, 2001 at 11:01 UTC ( #89239=note: print w/replies, xml ) Need Help??


in reply to 59 /e

I like this JAPH alot.
# # use strict or die # use strict; # # this is the command we use to start working on @_ in the s///e # my$s=';pop'; # # set $_ to be empty to start with # $_=''; # # a comment # # 59 /e, 2001 Philippe "BooK" Bruhat # # ??? # *_=*ARGV; # # set up @_ to contain our list of japh commands # @_=qw(4a4a2bfe01ac410d0105f4fd0dae30150dfab448f90208fa0d98 pop print+c +hr(shift) print+chr(shift) unshift@_,(shift()+shift())x2 push@_,(pop, +pop)x24 print+join"\n",@_; unshift@_,(map{unpack'c',$_}split//)[0..25 +] ; s/../chr(hex$&)/eg $_=substr(shift,0,52) @_=map{s|$|$s|s;$_}@_;po +p); # # start the chain of evals # s//$s/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee;
A breakdown of what the eval does (a JAPH in itself):

# # first we do the pop as stored in $s # pop(@_); # # the pop'ed command adds ";pop" to the end of each element of @_, the +n pops the next command off the @_ array # @_=map{s|$|$s|s;$_}@_; pop(@_); # # set $_ to "4a4a2bfe01ac410d0105f4fd0dae30150dfab448f90208fa0d98" and + pop # $_=substr(shift(@_),0,52); pop(@_); # # Transform each pair of hex digits into a character and pop # s/../chr(hex$&)/eg; pop(@_); # # pop # ;;pop(@_); # # unpack each of the first 25 characters in $_ and unshift them on to +the beginning of $_ and pop # unshift@_,(map{unpack'c',$_}split//)[0..25]; pop(@_); # # pop # ;;pop(@_); # # take the last 2 elements from $_ and put them back on the beginning +again. do this 24 times (so there should be 26 pairs of these command +s in all). then pop # push(@_,(pop(@_),pop(@_))x24); pop(@_); # # do these commands 26 times: # take two chars from @_, add them, put them back on @_ and then remov +e and print them # unshift(@_,((shift(@_)+shift(@_))x2)); pop(@_); print(chr(shift(@_))); pop(@_); # # finally print the last character # print chr(shift(@_)); pop(@_); # # and do some more pop'ing # pop(@_); pop(@_);

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://89239]
help
Chatterbox?
[Corion]: erix: Yes, but that's mostly for skipping characters you'll never read, but this approach skips the problem of needing to load more data while looking at a half-match
[Corion]: I mostly wonder how I can add this "reversal" to my toolchest, and if it's worth it or just clever
[choroba]: It should greatly simplify the parsing code, no flags or additional reading of the next buffer needed
[Corion]: choroba: Yeah, that's why I like that approach; it seems even quite obvious in retrospect to me, but many things are in hindsight ;)

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (13)
As of 2016-12-06 15:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (109 votes). Check out past polls.