#!/usr/bin/perl # Everything is a closure! use strict; use warnings; sub z(@); sub zz(&); z(map { my $z = $_; sub { $z } } map ord, split(//, zz { substr(scalar <DATA>, 2) }))->(); sub z(@) { my @z; my $z = sub($) { chr shift }; my $zz = sub($) { push @z, do { sub($) { my $zzz = shift; sub { $z->($zzz) }; } } ->(shift); }; do { my @z = @_; sub { foreach my $z ( @z ) { $zz->($z->()); } } }->(@_); do { sub { foreach my $z (@z) { print $z->(); } } }; } sub zz(&) { seek DATA, 0, 0; readline DATA; + shift->(); + } __END__ Everything is a closure!
Update: Yes, not everything is a closure. It's actually a bunch of misdirection. I hope.

Replies are listed 'Best First'.
Re: Everything is a closure
by merlyn (Sage) on Jan 20, 2005 at 20:04 UTC
      Yes, not everything is. It's just a joke I wrote when half dead from lack of sleep. Seemed funny at the time.

      And, of course, it's ugly. That is what counts, no?

Re: Everything is a closure
by BrowserUk (Patriarch) on Jan 20, 2005 at 16:24 UTC

    I'm getting

    substr outside of string at - line 10, <DATA> line 2. Use of uninitialized value in split at - line 10, <DATA> line 2.

    What did I do wrong?

    Update: Answer: I pasted the code directly into Perl at a command line rather than saving to a file and the running it. As the program attempts to seek on the DATA handle, it fails. Hence teh errors above. Ie. My problem not the obfu!


    Examine what is said, not who speaks.
    Silence betokens consent.
    Love the truth but pardon error.
      did you copy the
      __END__ Everything is a closure!
      part? i get Everything is a closure!

      holli, regexed monk

        Yes I did.... but I just remembered having a similar problem once before. It happens because I have a habit of pasting obfus directly into perl at a command line rather than into a file and then running them. And that is the problem again here. Run from within a file, I get that result also.


        Examine what is said, not who speaks.
        Silence betokens consent.
        Love the truth but pardon error.