Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Local(*FILE);

by clintp (Curate)
on Jan 13, 2002 at 02:05 UTC ( #138334=note: print w/ replies, xml ) Need Help??


in reply to Local(*FILE);

As others pointed out, it's not an initialization and serves to protect the filehandle from stomping on other filehandles of the same name (in the surrounding scope).

Additionally it has another effect: when you leave that scope the filehandle is closed automagically:

use warnings; { local *T; open(T, ">foo") || die; print T "HALHGLAG\n"; # Works okay! } print T "Surprise!\n"; # warns "print() on closed file..."


Comment on Re: Local(*FILE);
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2015-07-08 03:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (94 votes), past polls