Skip to content

Commit

Permalink
Update 09_running_cgi_scripts_on_plack.md
Browse files Browse the repository at this point in the history
Just a couple of small edits as I browse the text. :-)
  • Loading branch information
lancew committed May 28, 2014
1 parent 773d616 commit a756c37
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion en/09_running_cgi_scripts_on_plack.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
## Day 9: Running CGI scripts on Plack

For the couple of days we've been talking about how to convert existing CGI based applications to PSGI, and then run them as a PSGI application. Today we'd show you the ultimate way to run *any* CGI scripts as a PSGI application, most of the time unmodified.
For the last couple of days we've been talking about how to convert existing CGI based applications to PSGI, and then run them as a PSGI application. Today we will show you the ultimate way to run *any* CGI scripts as a PSGI application, most of the time unmodified.

[CGI::PSGI](http://search.cpan.org/perldoc?CGI::PSGI) is a subclass of CGI.pm to allow you a very easy migration from CGI.pm with only *a few lines of code changes* to run it on PSGI environment. But what about a messy or legacy CGI script that just prints to STDOUT a lot and is not easy to fix?

[CGI::Emulate::PSGI](http://search.cpan.org/perldoc?CGI::Emulate::PSGI) is a module to run any CGI based perl program in a PSGI environment. Whatever messy/old script that prints stuff to STDOUT or directly reads HTTP headers from `%ENV` would just work because that's what CGI::Emulate::PSGI tries to emulate. The original POD of CGI::Emulate::PSGI was illustrating it like:

```perl
use CGI::Emulate::PSGI;
CGI::Emulate::PSGI->handler(sub {
do "/path/to/foo.cgi";
CGI::initialize_globals() if &CGI::initialize_globals;
});
```

to run existing CGI application that may or may not use CGI.pm (CGI.pm caches lots of environment variables so it needs `initialize_globals()` call to clear out the previous request variables).

Expand Down

0 comments on commit a756c37

Please sign in to comment.