in reply to Cleaning up filehandles and directoryhandles
But I get the impression that fileno() doesn't work for directory handles.
So don't use it. close the filehandle unconditionally. If it's already closed, close may indicate an error by returning false, which you can ignore. In fact, you already ignore errors returned by close.
$_->close() foreach @openedFileHandles;
On the more general topic, this seems like a whole lot of work for something that should be handled by scope. File and directory handles are automatically closed when they go out of scope. It's much easier and safer to limit the scope of the handles than doing what you are attempting.
and I open my files like
And finally, it's very poor design for openFile's arguments to be in the reverse order of open's. Seeing that erodes my trust in the module, to say the least.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Cleaning up filehandles and directoryhandles
by anthski (Scribe) on Aug 10, 2005 at 07:51 UTC |