1Plack::App::CGIBin(3) User Contributed Perl DocumentationPlack::App::CGIBin(3)
2
3
4
6 Plack::App::CGIBin - cgi-bin replacement for Plack servers
7
9 use Plack::App::CGIBin;
10 use Plack::Builder;
11
12 my $app = Plack::App::CGIBin->new(root => "/path/to/cgi-bin")->to_app;
13 builder {
14 mount "/cgi-bin" => $app;
15 };
16
17 # Or from the command line
18 plackup -MPlack::App::CGIBin -e 'Plack::App::CGIBin->new(root => "/path/to/cgi-bin")->to_app'
19
21 Plack::App::CGIBin allows you to load CGI scripts from a directory and
22 convert them into a PSGI application.
23
24 This would give you the extreme easiness when you have bunch of old CGI
25 scripts that is loaded using cgi-bin of Apache web server.
26
28 This application checks if a given file path is a perl script and if
29 so, uses CGI::Compile to compile a CGI script into a sub (like
30 ModPerl::Registry) and then run it as a persistent application using
31 CGI::Emulate::PSGI.
32
33 If the give file is not a perl script, it executes the script just like
34 a normal CGI script with fork & exec. This is like a normal web server
35 mode and no performance benefit is achieved.
36
37 The default mechanism to determine if a given file is a Perl script is
38 as follows:
39
40 · Check if the filename ends with ".pl"
41
42 · Open the file and see if the shebang (first line of the file)
43 contains the word "perl"
44
45 You can customize this behavior by passing "exec_cb" callback, which
46 takes a file path to its first argument.
47
48 For example, if your perl-based CGI script uses lots of global
49 variables and such and are not ready to run on a persistent
50 environment, you can do:
51
52 my $app = Plack::App::CGIBin->new(
53 root => "/path/to/cgi-bin",
54 exec_cb => sub { 1 },
55 )->to_app;
56
57 to always force the execute option for any files.
58
60 Tatsuhiko Miyagawa
61
63 Plack::App::File CGI::Emulate::PSGI CGI::Compile Plack::App::WrapCGI
64
65 See also Plack::App::WrapCGI if you compile one CGI script into a PSGI
66 application without serving CGI scripts from a directory, to remove
67 overhead of filesystem lookups, etc.
68
69
70
71perl v5.12.3 2011-04-13 Plack::App::CGIBin(3)