Hey,
Unfortunately perl doesn't automatically localize $_ when using 'while
(<fh>) {...}'. Witness this one-liner:
% perl -MO=Deparse -e 'while(<>) {print}'
while (defined($_ = <ARGV>)) {
print $_;
}
So it'll clobber $_ with undef at the end of the block, and if $_ is
read-only then it'll fail with an error.
I recently ran across this when I got some death-errors in calling some
of the ExtUtils::Manifest functions from Module::Build. Those
functions fail if $_ contains an alias to a read-only variable:
% perl -MExtUtils::Manifest=maniread -e 'foo(5); sub foo{for(@_)
{maniread}}'
Modification of a read-only value attempted at
/Library/Perl/ExtUtils/Manifest.pm line 185.
The solution is to put "local $_;" before a few while(<fh>) loops in
ExtUtils::Manifest.
I'd submit a real patch, but:
% cvs up
cvs [update aborted]: connect to makemaker.org:2401 failed: Connection
refused
-Ken
Thread Next