How do I get a unique number to identify a reference? I could stringify it to something like "ARRAY(0x18045c0)", and then pull out the hex number with a regex, but I'm in a context where speed is a big deal. I was trying to do some magic with pack("P"), then unpack, but it's not working for me.

Oh yeah, it's gotta be portable, too. That is, the number itself can change from implementation to implementation, but in every environment it has to have the property of uniqueness. In particular, the Perl trick has to be work regardless of the integer and pointer sizes of the particular implementation.

(The reason I'm asking is I'm trying to do a Guttman-Rosler-Schwartz transform and some of the elements of the array I'm sorting are references to other arrays. I could put an arbitrary ID number in the subarrays as I create them and dereference the ID number for the sort, but I'm trying to save a few cycles. )


In reply to Unique numeric ID for reference? by Jeffrey Kegler

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.