Ever since Perl 5.6, this type of open has vivified a glob with a name like *_GEN_0. In your example, \*_GEN_0 == $fh will be true after opening the handle. The reason it is not freed when $fh goes out of scope is that the stash holds a reference to the handle, too.
There are two conceivable ways to solve this.
1) Don’t vivify a handle in the stash, but create an ‘anonymous’ handle named __ANONIO__, which already happens with other variations of the syntax.
2) Vivify a typeglob, but not in the stash (like __ANONIO__), but call in _GEN_0.
Whether we can do either depends on the answers to these questions:
• Is anybody depending on the name? (It certainly makes debugging easier than having multiple handles all named __ANONIO__.)
• Is anybody depending on being able to look up the name in the stash and find that same handle?
I don’t know the answers to those questions, which makes it hard to decide how to proceed. I would like to think that the answer to the second question is no (that nobody needs to access such filehandles by name).
Migrated from rt.perl.org#127692 (status was 'open')
Searchable as RT127692$
The text was updated successfully, but these errors were encountered: