in reply to references to elements of tied hashes

Any idea what's going on here? I'd expect a reference to $h->{FOO} to be the same as what it is when I first check it -- not change when passed to a sub
This behaviour is due to the fact that while tied hashes behave very much like real hashes, internally they're very different (I've had trouble with this, see. lvalue trickery). When you retrieve a value from a tied hash you get back a new value every time even if you are accessing the same value in the hash e.g
{ package MyTH; use Tie::Hash; @ISA = qw( Tie::StdHash ); sub FETCH { return $_[0]->{$_[1]} } } use Devel::Peek; tie my %h, "MyTH"; $h{foo} = 1; Dump($h{foo}) for 1 .. 3; __output__ SV = PVMG(0x811a810) at 0x811f4a4 REFCNT = 1 FLAGS = (TEMP,GMG,SMG,RMG) IV = 0 NV = 0 PV = 0 MAGIC = 0x8103ab8 ... SV = PVMG(0x811a810) at 0x811f4a4 REFCNT = 1 FLAGS = (TEMP,GMG,SMG,RMG) IV = 0 NV = 0 PV = 0 MAGIC = 0x8104480 ... SV = PVMG(0x811a810) at 0x811f4a4 REFCNT = 1 FLAGS = (TEMP,GMG,SMG,RMG) IV = 0 NV = 0 PV = 0 MAGIC = 0x8104480 ...
There a temporary value is created each time, but the value is always the same thing. Now if you create a reference you also get a temporary value, and stringified it will always change. What you're seeing in your code is that temporary reference being created each time and therefore a different stringification. So as you can see much 'magic' is going on behind the scenes of tied variables.
HTH

_________
broquaint