Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Destructive JAPH

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

Starting my foray into JAPH to explore various aspects and corners of the language. Not necessarily obfuscated, but more using different aspects of Perl to accomplish the goals of a JAPH. 4x79 code max, Just another Perl hacker, output to stdout. I am hoping to explore a different technique each day, but it will probably devolve to one a week.

This implementation is pretty obvious how it works, but it uses the DESTROY method of object destruction to output the characters of the output.

@x = map{ x($_) } split('','Just another Perl hacker,'); shift(@x) while @x; sub x{ bless \$_[0],"x"} sub x::DESTROY{print ${$_[0]}}

--MidLifeXis

Replies are listed 'Best First'.
Re: Destructive JAPH
by Grimy (Pilgrim) on Sep 03, 2013 at 18:04 UTC

    I wish you good luck on your journey through the darkest corners of Perl.

    Here’s a golfed and obfuscated JAPH using the DESTROY trick:

    sub'DESTROY{print${+pop}}bless\$_,for',rekcah lreP rehtona tsuJ'=~/./g

    The second argument of bless defaults to ::main, which is the package where subs declared without a package prefix go to. You don’t need the temporary array: the SV’s are still created and blessed even if map is used in void context (other built-ins, like sort, won’t let you do this). This causes them to be GC’d in reverse order, though.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2026-04-11 14:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.