> Is it possible to use hash reference as a key in another hash reference?

That's a classic! :)

Hash-keys are always stringified and there is no "direct" way to dereference the stringification.

BUT you are free to keep the original ref somewhere. Either as value in your data-structure or in a separate hash with $ref_of_str{"$key_hash"}=$key_hash. ¹

Thats much safer BTW cause a string doesn't increment the reference count ... i.e. keeping the reference somewhere protects the data from destruction if ref-count reaches 0.

(I hope it's clear now why dereferencing a string will hardly be ever possible)

HTH! :)

Cheers Rolf

(addicted to the Perl Programming Language)

update

¹) I rarely come into situations where I really need this trick. I'm sure your data-structure could be rewritten to avoid this, but tl;dr...


In reply to Re: Use a hashref as a key in another hashref? by LanX
in thread Use a hashref as a key in another hashref? by mwb613

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.