1Plack::App::CGIBin(3) User Contributed Perl DocumentationPlack::App::CGIBin(3)
2
3
4

NAME

6       Plack::App::CGIBin - cgi-bin replacement for Plack servers
7

SYNOPSIS

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

DESCRIPTION

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

HOW IT WORKS

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 given file is not a perl script, it executes the script just
34       like a normal CGI script with fork & exec. This is like a normal web
35       server 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". If yes, it is a Perl script.
41
42       •   Open the file and see if the shebang (first line of the file)
43           contains the word "perl" (like "#!/usr/bin/perl"). If yes, it is a
44           Perl script.
45
46       You can customize this behavior by passing "exec_cb" callback, which
47       takes a file path to its first argument.
48
49       For example, if your perl-based CGI script uses lots of global
50       variables and such and are not ready to run on a persistent
51       environment, you can do:
52
53         my $app = Plack::App::CGIBin->new(
54             root => "/path/to/cgi-bin",
55             exec_cb => sub { 1 },
56         )->to_app;
57
58       to always force the execute option for any files.
59

AUTHOR

61       Tatsuhiko Miyagawa
62

SEE ALSO

64       Plack::App::File CGI::Emulate::PSGI CGI::Compile Plack::App::WrapCGI
65
66       See also Plack::App::WrapCGI if you compile one CGI script into a PSGI
67       application without serving CGI scripts from a directory, to remove
68       overhead of filesystem lookups, etc.
69
70
71
72perl v5.38.0                      2023-07-21             Plack::App::CGIBin(3)
Impressum