Plack::App::CGIBin(3)
π Plack::App::CGIBin(3) β the cgi-bin glow-up π
okay so bestie, this is the perl doc for Plack::App::CGIBin β yes, the whole manual page, and yes, we're doing this together. grab a boba. π§
β¨ NAME β¨
Plack::App::CGIBin β it's literally a cgi-bin replacement for Plack servers. she serves the same energy but cuter. π
πΈ SYNOPSIS πΈ
the way you just drop her in:
use Plack::App::CGIBin;
use Plack::Builder;
my $app = Plack::App::CGIBin->new(root => "/path/to/cgi-bin")->to_app;
builder {
mount "/cgi-bin" => $app;
};
# Or from the command line
plackup -MPlack::App::CGIBin -e 'Plack::App::CGIBin->new(root => "/path/to/cgi-bin")->to_app'
like. it's giving effortless. π
π¦ DESCRIPTION π¦
so Plack::App::CGIBin lets you load CGI scripts out of a directory and convert them into a PSGI application. iconic behaviour honestly.
and the reason you'd want this? extreme easiness π
β when you have a whole bunch of old CGI scripts that used to be loaded through the cgi-bin of an Apache web server, this is your girl. no cap.
π₯ HOW IT WORKS π₯
story time. this application checks whether a given file path is a perl script, and if it is, it uses CGI::Compile to compile that CGI script into a sub (like ModPerl::Registry does) and then runs it as a persistent application using CGI::Emulate::PSGI. queen shit. π
if the given file is not a perl script, she executes the script just like a normal CGI script with fork & exec. this is like a normal web server mode and no performance benefit is achieved β so like, don't expect the glow-up there, bestie. π
the default mechanism to figure out if a given file is a Perl script goes like this:
- Check if the filename ends with
.pl. If yes, it is a Perl script. - Open the file and see if the shebang (first line of the file) contains the word
perl(like#!/usr/bin/perl). If yes, it is a Perl script.
you can customize this behavior by passing the exec_cb callback β it takes a file path as its first argument. π«Ά
for example, if your perl-based CGI script uses lots of global variables and such and is not ready to run in a persistent environment, you can do:
my $app = Plack::App::CGIBin->new(
root => "/path/to/cgi-bin",
exec_cb => sub { 1 },
)->to_app;
to always force the execute option for any files. boom. π
π AUTHOR π
Tatsuhiko Miyagawa β the main character fr fr.
π SEE ALSO π
Plack::App::FileCGI::Emulate::PSGICGI::CompilePlack::App::WrapCGI
also see Plack::App::WrapCGI if you compile one CGI script into a PSGI application without serving CGI scripts from a directory β that way you can remove overhead of filesystem lookups, etc. iykyk β
lowkey reminder: this page lives in the perl docs,perl v5.42.3, dated2026-10-18, and it'sPlack::App::CGIBin(3). that's the whole vibe. slay, go mount your cgi-bin, periodt. πβ¨π¦
π¦ where this page comes from
- fedora 43: perl-Plack 1.0055-1.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- fedora 44: perl-Plack 1.0055-1.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms