Subject: | global variable $_ will be destroyed |
1032 # Restore replacements done earlier:
1033 my $i = scalar(@repl);
1034 $text =~ s|<textile#$i>|$_|, $i-- while $_ = pop @repl;
better:
1034 $text =~ s|<textile#$i>|$_|, $i-- while local $_ = pop @repl;
Script to catch:
---------------------------------------------------------------
tie $_, 'Tie::Global::Var', $_;
$_ = 'destroy';
untie $_;
---------------------------------------------------------------
package Tie::Global::Var;
use strict;
use warnings;
sub TIESCALAR {
my ($class, $value) = @_;
return bless \$value, $class;
}
sub FETCH {
my $self = shift;
return $$self;
}
sub STORE {
my ($self, $value) = @_;
if (1) {
$value = 'undef' if ! defined $value;
my @caller_all;
my $index = 0;
while (my ($package, undef, $line) = caller $index++) {
push @caller_all, "$value at $package line $line";
}
my $caller_all = join '; ', @caller_all;
chomp $caller_all;
warn($caller_all);
}
$$self = $value;
return $self;
}
sub DESTROY {
my $self = shift;
$$self = ();
}