in reply to Re: Re: What would you do?
in thread What would you do?
Your comment and several others I have seen here suggest that while(FH) and foreach automatically localize $_. But the folowing code seems does not revert to the old $_ after leaving the while loop. What am I missing? Thanks.
use strict; use diagnostics; $_ = "Before"; print "Before loop= $_\n"; while (<>){ print "In while loop= $_\n"; last; } print "After while loop= $_\n"; Output: Before loop= Before myinput (entered from the keyboard) In while loop= myinput After while loop= myinput
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Does while localize $_?
by danger (Priest) on Mar 19, 2001 at 00:07 UTC | |
Re: Does while localize $_?
by merlyn (Sage) on Mar 19, 2001 at 00:07 UTC | |
by tenya (Beadle) on May 25, 2001 at 07:46 UTC |
In Section
Seekers of Perl Wisdom