On Jul 15, Randy W. Sims said: >> Using the <FH> operator implicitly assigns to $_, without localizing it. >> Therefore, if you're going to use 'while (<FH>)', please local()ize $_ >> first. > >That's got me wondering: are there any more operators or constructs that >clobber $_ ? A few experiments show that C<for>, C<map> all localize $_.
I don't believe any of them clobber $_. The only reason <FH> does is because the construct: while (<FH>) is turned into while ($_ = <FH>) which in turn becomes while (defined($_ = <FH>)) Which is why you never have to write while (defined(my $x = <FH>)) because Perl turns while (my $x = <FH>) into that for you. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ % -- Meister Eckhart -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
