Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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
Replies are listed 'Best First'.
Re^2: plackup problem
by Your Mother (Chancellor) 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 examining the Monastery: (14)
As of 2015-07-28 11:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (254 votes), past polls