"be consistent" | |
PerlMonks |
Re: Localizing an indirect filehandleby Joost (Canon) |
on Dec 10, 2008 at 18:19 UTC ( [id://729473]=note: print w/replies, xml ) | Need Help?? |
If anybody still cares to add to my understanding I'm always grateful.FILEHANDLE style file handles are a built-in data type distinct from scalars, hashes, arrays, refs, formats etc. They're also always global (either really global, for the STD* handles, or package-bound). $file_handle style handles are real variables and so they get the same scoping / semantics as any other variable, specifically: 1. local()izing a variable does NOT declare it. IOW, you still need to use our() in whatever scope(s) you use the variable, or use vars. 2. if you declare the $handle variable to be a lexical, you can't local()ize it either (you can try, but you'll be localizing the package variable of the same name instead). 3. strict throws an error if you use an undeclared non-automatic global/package variable.
In Section
Seekers of Perl Wisdom
|
|