Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

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.


Comment on Re: plackup problem
Select or Download Code
Re^2: plackup problem
by Your Mother (Canon) 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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1061874]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2014-07-26 02:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls