G
George Mpouras
how do I know if a directory is open so not have warnings when closedir
it ? At files there is the fileno.
it ? At files there is the fileno.
George Mpouras said:how do I know if a directory is open so not have warnings when closedir
it ? At files there is the fileno.
how do I know if a directory is open so not have warnings when closedir it ? At files there is the fileno.
y $dh;
opendir $dh, $_ or do { warn "open $_ failed: $! ($^E)\n"; undef $dh; };
...
readdir $dh, ...
...
closedir $dh if $defined $dh;
George Mpouras said:Στις 2/11/2013 7:37 πμ, ο/η $Bill ÎγÏαψε:
this is a very good idea.
To a degree: perl knows if the directory handle is open and will close
it automatically when the corresponding object is destroyed. This means
this will work:
my $dh;
opendir($dh, '/tmp') if rand(10) > 5;
$dh = undef;
Στις 2/11/2013 7:37 πμ, ο/η $Bill ÎγÏαψε:
this is a very good idea.
I wonder where is this Perl mystic cryptic where the handles are kept.
fileno knows it , but dirhandles are not there , but there must be also
one for the dirhandles
I don't think this helps, does it? You still need eval if you want to
pass in arbitrary scalars.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.