Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: checking bareword-filehandle

by moritz (Cardinal)
on Aug 06, 2012 at 13:18 UTC ( #985702=note: print w/replies, xml ) Need Help??


in reply to checking bareword-filehandle

Is there a good reason not to use a lexical variable as file handle?

open my $FH, '>', 'whatever' or warn 'blah'; # much much later if ($FH) { print $FH "something }

works for sure.

Replies are listed 'Best First'.
Re^2: checking bareword-filehandle
by morgon (Curate) on Aug 06, 2012 at 13:24 UTC
    Evidently, but at the moment the open is in a different lexial scope as the print so I would need to declare a lexical $FH in the common enclosing scope - I'll do that eventually.

    But apart from your suggestions for suppressing the warning outright - is there really no easy way for checking such a handle?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://985702]
help
Chatterbox?
[marinersk]: That seems a bit harsh. A newspaper deletes a picture and you respond by deleting a whole city?
[LanX]: yep
[Corion]: First he deleted Bielefeld, now he threatens to delete Darmstadt!
[marinersk]: LOL
[Corion]: People claim that Bielefeld exists, but that's just a ploy to hide LanX's acts!

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2017-05-29 14:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?