Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: plackup problem

by three18ti (Scribe)
on Nov 09, 2013 at 22:47 UTC ( #1061874=note: print w/replies, xml ) Need Help??

in reply to plackup problem

You're just declaring a subroutine, there's no $app variable, which is what plackup is looking for.

Look at your example again:

my $app = sub { return [ 200, [ 'Content-Type' => 'text/plain' ], ['Hello World'], ]; };

Instead of declaring a subroutine, they are creating an anonymous sub and assigning it to the variable $app.

To make your code work, try the following:

my $app = \&app; sub app { my $env = shift; return [ '200', [ 'Content-Type' => 'text/plain' ], [ "Hello World" ] ]; }

This version assigns a reference to the subroutine app to the variable $app, which is the code reference plackup is looking for.

Replies are listed 'Best First'.
Re^2: plackup problem
by Your Mother (Bishop) on Nov 10, 2013 at 00:47 UTC

    That works. But so does changing the $app line to this–

    my $snuffleupagus = \&app;

    From the docs–

    The last statement of app.psgi should be a code reference that is a PSGI application:

    The last statement isn't the sub declaration, it's the assignment. The variable name is meaningless. I personally prefer to just do an anonymous sub { … } as the last or only statement in this kind of test/one-off. But that’s only a style choice.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1061874]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2018-04-22 22:36 GMT
Find Nodes?
    Voting Booth?