Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Localizing an indirect filehandle

by Joost (Canon)
on Dec 10, 2008 at 18:19 UTC ( [id://729473]=note: print w/replies, xml ) Need Help??


in reply to Localizing an indirect filehandle

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://729473]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-25 05:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found