Subject: | Evil sub called from finally { } block can modify $@ for Perl >= 5.013002 |
Test code:
sub evil_sub {
$@ = "another magic";
}
{
local $@ = "magic";
local $_ = "other magic";
try {
1;
} catch {
fail("shouldn't happen");
} finally {
evil_sub;
};
is( $@, "magic", '$@ untouched' );
is( $_, "other magic", '$_ untouched' );
}
This code passes only when UNSTABLE_DOLLARAT is true which is for Perl < 5.013002. For all new Perl versions this code fails.