I'm trying to understand how lexical filehandles are dumped:
> perl use Data::Dumper qw/Dumper/; use Data::Dump; open my $fh,"<",'/tmp/tst'; dd $fh; dd $::{'$fh'}; print Dumper $fh; __END__ \*main::$fh undef $VAR1 = \*{'::$fh'};
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:
dd *{'::$fh'}; # => *main::$fh
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 ?
Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
In reply to dumping lexical filehandles (updated) by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |