Perl CGI Scripts are cached after switching to mod_perl

I recently had to port a very old perl project to a new server, which is running mod_perl- that made me some headache as I didn’t know anything about that environment.

Pages with dynamic form input from CGI::param suddenly seemed to be “cached”, the script did process old variables and emitted wrong output. After diggin’ into mod_perl with this great article the solution was quite easy.

mod_perl somehow keeps a persistent process environment, thus restoring variables declared with my. As I didn’t want to rewrite the whole thing I simply changed lines like

my $type = param("type");

to

local $type = param("type");

and everything works fine and “uncached”. I know there are several pitfalls with local again, anyway, I’m not into mod_perl, things seem to work and a 10-years old medieval project’s running again.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s