No such thing as a small change | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
The use of plackup in a shebang line for CGI scripts is documented in Plack::Handler::CGI. If you're interested in how/why it works, read on. plackup's normal behaviour is to run a server which listens on a TCP port, and handles multiple HTTP requests, and keeps going until it gets killed. You can observe this behaviour by running:
It will print out a URL; you can paste that into your browser, and it will serve up a small text file containing the word "ok". And you can hit "reload" and it will do it again and again. Awesome. But, of course, not what you want from a CGI script! So how is plackup any good in a shebang line? Hit Ctrl+C to kill plackup, and then set the following environment variables:
Now run this again:
And you'll see that instead of spawning an HTTP server and printing out its address for you, plackup now behaves like a CGI script, printing out the response headers and body to STDOUT. plackup (or rather the guess sub defined in Plack::Loader) detects that it's running in a CGI environment and behaves appropriately. In reply to Re^3: Change cgi script to PSGI app
by tobyink
|
|