in reply to Re^4: symbol/glob hash explanation
in thread symbol/glob hash explanation
Looking into Symbol, that is apparently deliberate:
my $genpkg = "Symbol::"; my $genseq = 0; sub gensym () { my $name = "GEN" . $genseq++; ## Instantiate the glob and take a reference to it. my $ref = \*{$genpkg . $name}; ## Delete the name, leaving a reference to an anonymous glob delete $$genpkg{$name}; ## return the ref $ref; }
Thus, it effectively mirrors the behaviour [] and {} in that you have a reference to a structure that doesn't (no longer) appears in the pad (symbol table).
The few times I've wanted an anonymous glob I've used:
$r = do{ \local *FRED };; print $r;; GLOB(0x4055f70)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: symbol/glob hash explanation
by rwstauner (Acolyte) on May 03, 2011 at 16:55 UTC |