Don't ask to ask, just ask | |
PerlMonks |
Re^4: When do filehandles close?by gaal (Parson) |
on Jul 23, 2004 at 08:01 UTC ( [id://376824]=note: print w/replies, xml ) | Need Help?? |
(Thanks for the typo spotting; fixed.)
The $. behavior here is correct, if highly magical. Perl is keeping track of a property of an object that doesn't exist any more. (Or, looking at it another way, it's not magical at all: $. is a global that gets set whenever a filehandle is accesed. Even if the handle is closed, the global remains. But there's still something DWIMmish going on, because each (active) filehandle does remember its own line number, so that when you access two files in alternation, $. knows how to keep track. s/line number/record number/g for exactness.)
In Section
Seekers of Perl Wisdom
|
|