http://qs321.pair.com?node_id=376759


in reply to When do filehandles close?

Just for completeness, one other time when filehandles close is when you call close() on them. Also, please take a look at open() in perlfunc, where it says this:

Using the constructor from the "IO::Handle" package (or one of its subclasses, such as "IO::File" or "IO::Socket"), you can generate anonymous filehandles that have the scope of whatever variables hold references to them, and automatically close whenever and however you leave that scope: