LanX has asked for the wisdom of the Perl Monks concerning the following question:
and in my tests it does, but I don't really understand why, because $_[0] is supposed to be a reference(!) and is not properly dereferenced here. Looking into the source of Tie::Hash reveals the expected usage.sub STORE { warn "Storing data with key $_[1] at $_[0].\n"; $_[0]{$_[1]} = $_[2] }
I'm confused, is there any aliasing magic in $_[0] making it act as a non-refrence hash variable?package Tie::StdHash; ... sub TIEHASH { bless {}, $_[0] } sub STORE { $_[0]->{$_[1]} = $_[2] }
Cheers Rolf
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Confused about $self in Tie::Hash
by choroba (Cardinal) on Oct 12, 2011 at 15:48 UTC | |
by LanX (Saint) on Oct 12, 2011 at 15:55 UTC |