Plack::...:WrapCGI(3)

πŸ’– Plack::App::WrapCGI πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation and it's about Plack::App::WrapCGI β€” the little icon that Compiles a CGI script as PSGI application. yes that's the whole name. it literally does what it says on the tin and I'm obsessed πŸŽ€


✨ NAME ✨

Plack::App::WrapCGI β€” Compiles a CGI script as PSGI application πŸ¦‹


🌸 SYNOPSIS 🌸

the way you just... do this. simple. clean. no notes:

use Plack::App::WrapCGI;

my $app = Plack::App::WrapCGI->new(script => "/path/to/script.pl")->to_app;

# if you want to execute as a real CGI script
my $app = Plack::App::WrapCGI->new(script => "/path/to/script.rb", execute => 1)->to_app;

see that second one? that's the execute => 1 era. when you wanna run it as a real CGI script. periodt πŸ’…


πŸ’œ DESCRIPTION πŸ’œ

so Plack::App::WrapCGI takes a CGI script and compiles it into a PSGI application, using CGI::Compile and CGI::Emulate::PSGI as the whole support system behind the scenes (they're doing the heavy lifting, we love them 🫢), and then it just... runs it with any PSGI server, as a PSGI application. that's it. that's the vibe check and it passed βœ…

also πŸ‘€ β€” if you have a whole directory stuffed with a ton of CGI scripts and you wanna serve them the way Apache's mod_cgi does, you want Plack::App::CGIBin instead. different app, same energy. iykyk


πŸŽ€ METHODS πŸŽ€

new

my $app = Plack::App::WrapCGI->new(%args);

creates a new PSGI application using the script you handed it. %args takes exactly two parameters and here they are, no gatekeeping:

  • script β€” the path to a CGI-style program. this one is the required parameter, like you literally cannot skip it bestie, it's the whole point 😭
  • execute β€” an optional parameter. set it to a true value and this app will run the script with a CGI-style fork/exec model. and the fun part?? you can run programs written in other languages with this approach. iconic behavior honestly πŸ‘‘
lowkey important: execute being optional means if you don't pass it, you're not getting the fork/exec treatment. don't be surprised later. fr fr πŸ™ˆ

πŸ‘‘ AUTHOR πŸ‘‘

Tatsuhiko Miyagawa

(genius. legend. mother. ate and left no crumbs ✨)


🌈 SEE ALSO 🌈

  • Plack::App::CGIBin

and that's the whole page bestie!! this was Plack::App::WrapCGI(3) from the User Contributed Perl Documentation, and the footer said perl v5.42.3 dated 2026-10-18 β€” so yeah, this doc is from the future and it still slays πŸ’–πŸ’…πŸ¦‹πŸŒΈβœ¨πŸŽ€πŸ«Ά

πŸ“¦ where this page comes from