|Pathologically Eclectic Rubbish Lister|
dumping lexical filehandles (updated)by LanX (Sage)
|on Sep 12, 2014 at 15:11 UTC||Need Help??|
LanX has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to understand how lexical filehandles are dumped:
apparently $fh holds the ref to a glob named "\$fh" , i.e. with sigle as part of the name!
But inspecting the STASH doesn't show this entry...
I know that the common way to copy a bare filehandle to a scalar is my $fh=\*FH but this is confusing me.
Is this an implementation workaround or what am I missing?
Just after posting I'm realizing that I may be inspecting the wrong ($ = scalar) slot of the $fh glob. I'll update further tests.
OK inspecting only the glob reveals it's existence in the stash:
but I'm still a bit confused ...
So lexical file handles are implemented as hidden global stash entries, which are destroyed when the lexical var falls out of scope ?
(addicted to the Perl Programming Language and ☆☆☆☆ :)