plack/Plack — pull request #333 by avar (2012-09-27 15:47:13+00:00)
Title: Plack::Handler::Apache[12]: delete $ENV{MOD_PERL}, don't just localize i...

...t

Some software such as CGI::Cookie does C to
check if it's running under mod_perl instead of just checking whether
$ENV{MOD_PERL} is true.

Fix this by locally deleting $ENV{MOD_PERL} instead of just setting
its value to undef.

I hadn't used this construct before so I thought I'd check if it works
under a multitude of Perl versions, it works on at least 5.8.5 and
5.14.2:

$ perl -MData::Dumper -wle 'print $]; my %hash = qw(a b c d); { delete local $hash{a}; print Dumper \%hash } { local $hash{a}; print Dumper \%hash; }'
5.008005
$VAR1 = {
'c' => 'd'
};

$VAR1 = {
'c' => 'd',
'a' => undef
};

$ perl5.14.2 -MData::Dumper -wle 'print $]; my %hash = qw(a b c d); { delete local $hash{a}; print Dumper \%hash } { local $hash{a}; print Dumper \%hash; }'
5.014002
$VAR1 = {
'c' => 'd'
};

$VAR1 = {
'c' => 'd',
'a' => undef
};