wouldn't you want the class attributes to exist until the program terminated in case you created a new instance after all the others where destroyed?

In many cases, I'd expect that to be true, yes. Part of my background for this, however, is that one of these class attributes holds a large data structure that I don't want to hold in memory. There could be other reasons for wanting one thing shared by all instances that you also want to deallocate when there are no more instances.

It would seem that its just grabbing the first key in the hash regardless of what it is.

Yes, that's exactly what it does. It finds any other instance of the same class. if there is no other instance, $other_ident will be undef. If there is some other instance, I take a copy of that instance's class attribute reference. Since they all have the same reference, it doesn't matter which one I get.


In reply to Re^4: Garbage collected class attributes with inside out classes. by kyle
in thread Garbage collected class attributes with inside out classes. by kyle

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.