in reply to array reference as hash key

Unfortunetly, you cannot use a reference as a hash key. Look in "References Don't Work as Hash Keys" in the camel book (3rd ed.) page 265.

Replies are listed 'Best First'.
Re: Re: array reference as hash key
by rjray (Chaplain) on Feb 26, 2002 at 04:07 UTC

    You can use a reference as a hash key, it just is not useful to do so. The reference will be stringified, and cannot be converted back to the data it originally referred to. The Perl References manual page covers this towards the end, under the appropriate heading of "WARNING".

    The exact same reference will always stringify the same way, and in that sense it could be used with effect as a hash key. However, you would still have to have another means by which to map the stringified key back to the original ref. The section above gives one example of how to do this.

    --rjray