in reply to using references as keys in a hash.

Correct, it is not a reference any more. Hash keys are strings, and the reference has been stringified to fit. That is 'planned', so to speak, by the key hashing algorithm.

That's not to say it is useless. References to distinct variables make fine keys, guaranteed to be unique.

After Compline,
Zaxo

  • Comment on Re: using references as keys in a hash.

Replies are listed 'Best First'.
Re: using references as keys in a hash.
by Abigail-II (Bishop) on Feb 23, 2003 at 02:38 UTC
    They are only unique as long as the variable(s) exist. If they are garbage collected, Perl will reuse the memory for it, and it could be a new reference stringifies to the same value as the old one.

    Abigail