Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: How can you check to see if a file handle is already open?

by mifflin (Curate)
on Jan 16, 2008 at 19:58 UTC ( #662748=note: print w/replies, xml ) Need Help??


in reply to Re^2: How can you check to see if a file handle is already open?
in thread How can you check to see if a file handle is already open?

Why not just use the IO::Handle package?

Use the opened method. It will tell you if a file handle is opened and ready.

try the following code...

use strict; use warnings; use IO::Handle; open my $fh, '>', 'file' or die $!; test_fh($fh); close $fh or die $!; test_fh($fh); sub test_fh { my ($fh) = @_; if ($fh->opened()) { print "fh is opened and ready\n"; } else { print "fh is closed\n"; } return; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://662748]
help
Chatterbox?
[perldigious]: w4st3 n0t w0t n0t
thezip is randomly reminded of Hugo's_house_of_ho rrors

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (14)
As of 2017-03-24 18:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (305 votes). Check out past polls.