Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Reference as a hash keyby AnomalousMonk (Archbishop) |
on Aug 25, 2009 at 16:05 UTC ( [id://791122]=note: print w/replies, xml ) | Need Help?? |
It depends on just what you want to do with the keys of your hash.
As you see, all hash keys are stringified, so the keys can never again be used as references (the original references are unaffected). However, they are stringified uniquely because each reference has a unique address, so I see no problem with using the string representation to flag that a particular array has been handled. Of course, if the referent of a reference is destroyed, the hash key corresponding to it is unaffected! You have to take care of this on your own. And remember: if references are destroyed and new ones created, old reference addresses may be re-used! Actually, I think I would tend to use something like bluestar's suggestion in Re: Reference as a hash key: it's more general and flexible, probably more maintainable. Updates:
In Section
Seekers of Perl Wisdom
|
|