Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: localization of $_

by TheoPetersen (Priest)
on Feb 28, 2001 at 00:03 UTC ( #61150=note: print w/replies, xml ) Need Help??

in reply to localization of $_

It's a common enough situation. I think a lot of us figured it out in just this way too.

perlman:perlsub, perlman:perlsyn and perlman:perlvar all have some comments about this, but it can be hard to get the picture from those without someone (or some bug) pointing it out. perlman:perlvar states that $_ is assigned to in your while case, but doesn't make it clear that $_ isn't localized by while as a foreach would.

Either localize $_ yourself, or switch to another while style for any loop that calls subroutines: while (my $line = <FILE>) {

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://61150]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2023-09-30 23:03 GMT
Find Nodes?
    Voting Booth?

    No recent polls found