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