hmm just a (maybe not too) strange thought ...

... if these are just plain arr-refs and not already blessed obj-refs you might use a simple hack to flag them with attributes :

You may bless them into a package _SEEN_ and check it with ref ! 8)

DB<1> $arr=[] DB<2> bless $arr,"_SEEN_" DB<3> p ref $arr _SEEN_ DB<4> bless $arr,"_UNSEEN_" DB<5> p ref $arr _UNSEEN_

You wont have any collision risk and you can safely pass the refs around with the information attached without caring about any extra %seen hash.

Cheers Rolf

UPDATE: I just noticed that (unfortunately) there is no way to "unbless" references in perl afterwards! :-(

You may write bless $arr,"ARRAY" to try undoing blessing but even if ref now returns "ARRAY" it's NOT the same as "unblessing" and may cause subtle bugs ... just check it with Scalar::Util::blessed $arr ! Pity!


In reply to Re^2: Reference as a hash key (bless hack) by LanX
in thread Reference as a hash key by Anonymous Monk

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.