Reputation: 2199
my $r = shift || Apache2::RequestUtil->request;
my $request = Apache2::Request->new($r, @_);
I know it was designed to be used with mod_perl,
but is there a workaround so that it can also be used in CGI mode?
Upvotes: 1
Views: 148
Reputation: 7018
Have you tried replacing those two lines with ...
my $request = CGI->new();
The Apache2::Request module wraps the mod_perl API in order to "mimic the CGI.pm routines for parsing query parameters". So any code that uses the raw $r won't work, but code using $request might.
But in answer to your bigger question, the answer is no there isn't an easy way to run code written for mod_perl under CGI instead. When writing new code you should either use a framework or write to the PSGI API which can then me deployed using CGI, FastCGI or mod_perl without changing the code.
Upvotes: 1