Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Felling a tree JAPH

by MidLifeXis (Monsignor)
on Aug 30, 2013 at 14:28 UTC ( [id://1051644]=obfuscated: print w/replies, xml ) Need Help??

Still not a great JAPH, and it exceeds 4x79, but it is more obfuscated than yesterday's.

# Cutting down a tree $t=t->p;$t->g;$t->f;sub t::p{@n=map{x($_)}'Just another Perl hacker,'= +~m/(.)/g; bless{n=>\@n},$_[0]}sub t::g{$_[0]->{t}=$_[0]->f(0,$#{$_[0]->{n}});$_[ +0]->{n}=1 ;$_[0]}sub t::f{($a,$b,$e)=@_;$m=int(($b+$e)/2);$f=$_[0]->{n}[$m];$l=$ +_[0]->f( $b,$m-1)if$b<$m;$r=$_[0]->f($m+1,$e)if$m<$e;bless [$l,$f,$r],'f'}sub t +::f{$_[0] ->{t}=1}sub x{bless \$_[0],"x"}sub x::DESTROY{print${$_[0]}}sub f::DES +TROY{$_[0 ]->[$_]=1 for(0..2)}

--MidLifeXis

Replies are listed 'Best First'.
Re: Felling a tree JAPH
by Grimy (Pilgrim) on Sep 03, 2013 at 20:28 UTC
    Which version of Perl are you using? I am getting the following outputs:
    ~$ perl5.10.1 japh r Perl hacker,Just anothe ~$ perl5.16 japh er Perl hacker,Just anoth

      Interesting. 5.8.9, Windows.

      $ perl 20130830.japh.pl Just another Perl hacker,

      Do you get the same results every time, or does it change on each run?

      Update: s/Win/Windows/ for clarity :-)

      --MidLifeXis

        For a given version, I get a consistent result. I reckon the discrepancies between different version are due to internal changes to the GC.

        Relying on DESTROY is problematic, because the order in which thingies are GC’d is unspecified.

Re: Felling a tree JAPH
by Grimy (Pilgrim) on Sep 04, 2013 at 14:17 UTC

    This 4x48 snippet prints JAPH on all Perl version I tested it on.

    sub'DESTROY{print${sub'_(_){bless\pop}pop}->[0]} _[J,_[q q q,_[o^O,_[q[,]],_[k,_[r],_[e]],_[h,_[c ],_[a]]],_[P,_[n&_],_[r],_[e],],],_[u,_[a,_[h,_[ r],_[e],],_[n,_[t],_[o],],],_[q[s],_[$"],_[t]]]]

    It still uses the “chopping a tree” concept, but the tree is hard-coded, rather than being built dynamically based on a string.

    Here it is with indentation to evidence the tree’s structure:

    _[J, _[q[ ], _[q[ ], _[q[,]], _[k, _[r], _[e] ], _[h, _[c], _[a] ] ], _[P, _[l], _[r], _[e], ], ], _[u, _[a, _[h, _[r], _[e], ], _[n, _[t], _[o], ], ], _[q[s], _[q[ ]], _[t] ] ] ];
      $ perl -v This is perl, v5.8.8 built for msys $ perl 20130830.1052349.japh.pl Malformed prototype for main::_: _ at 20130830.1052349.japh.pl line 2.

      --MidLifeXis

        Well then, just replace this _ with a $. It should work the same way, I only chose _ for aesthetic reasons.

        EDIT: Never mind trying, it won’t work, actually. Here’s a fixed version:

        sub'DESTROY{print${sub'_($){bless\pop}pop}->[0]} _[J,_[q q q,_[o^O,_[q[,]],_[k,_[r],_[e]],_[h,_[c ],_[a]]],_[v80,_[l],_[r],_[e],],],_[u,_[a,_[h,_[ r],_[e],],_[n,_[t],_[o],],],_[q[s],_[$"],_[t]]]]
        Tested on 5.8, 5.10, 5.14 and 5.16.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: obfuscated [id://1051644]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-03-29 14:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found