Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
go ahead... be a heretic
 
PerlMonks  

Re: localization of $_

by TheoPetersen (Priest)
on Feb 27, 2001 at 19:03 UTC ( [id://61150]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://61150]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.