in reply to Need Help in Understanding Some Code - Map and Scalar Questions

Maybe I'm having a senior moment here, but I can't see how the statement in the OPed code
    sub { ... };
    # wander away...
can possibly do anything at all.

One could define and subsequently invoke a subroutine
    sub func { ... }
    # some other stuff...
    func();
or define and save a reference to a subroutine and subsequently invoke it
    my $coderef = sub { ... };
    # some other stuff...
    $coderef->();
or define a reference to a subroutine and immediately invoke it
    sub { ... }->();
but I don't understand the definition of the OPed code, which just seems to define a subroutine reference and then immediately throw it away.

Am I missing something?

Replies are listed 'Best First'.
Re^2: Need Help in Understanding Some Code - Map and Scalar Questions
by Your Mother (Archbishop) on Oct 31, 2010 at 03:33 UTC
    Maybe I'm having a senior moment here…

    Hee-hee. The code was contained in a script called proc.psgi so it's final value is an anonymous sub. Somewhat like a module must return true, a PSGI app must return its code ref. See http://plackperl.org/. Plack is all kinds of wonderful.

      ... a PSGI app must return its code ref.

      Ah, the mist begins to clear.