in reply to What is HASH(0x17653d4) for?
However if you allocate, free, then reallocate a variable, the second one may be used where the first one was. For instance consider this code:
If you run that, you will find that the first two references that were generated at different times were named the same as each other. But when you tried to create a new one while the old one existed, Perl gave it a different name. So if the hash keys live longer than the references you are indexing into, then you may have a problem.sub gen_ref { [@_]; } print gen_ref(), "\n"; my $keep_ref = gen_ref(); print $keep_ref, "\n"; print gen_ref(), "\n";
What is going on behind the scenes is that the name specifies the memory location where you used the data. And if Perl can it reuses the old memory location. If that is in use, then it uses a new one.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re (tilly) 1: What is HASH(0x17653d4) for?
by Tetramin (Sexton) on Nov 02, 2001 at 02:03 UTC | |
by tilly (Archbishop) on Nov 02, 2001 at 02:21 UTC | |
by fokat (Deacon) on Nov 02, 2001 at 03:16 UTC |