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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.