Some time ago, I dabbled in amatuer astronomy. One thing I learned while looking at an object is sometimes you can see it better by not looking directly at it. Problem with that for me was it was hard not to look directly at the object and if I did view it out of the corner of my eye, I never felt like I was really seeing it. This is how I have felt recently about anonymous data structures.

Recently, I had the opportunity to use an anonymous array appropriately in my code. I put it in, it worked, and at the time I did that I understood, or at least I thought I understood, what it was doing and how it worked. But the more I looked at the code and the more I read about anonymous arrays (in this case) the less I understood. In fact, the information I have read so far has been left me wanting more.

So, my question is how do these work, internally I mean. I understand that I create the sturcture, it has no name which leaves it without a way to call it directly. This worked in my case because I was iterating over the same array and making it anonymous allowed it to "recreate" itself anew. But HOW does Perl understand this. It is hard to imagine that Perl can access any data structure without some sort of name associated with it. Is it just sort of a "natural reference" with a reference but no name, and if that is the case how does this get handled vis-a-vis the garbage handled alogrithms.

I realize this is an esoteric subject, and I am sure my writting skills don't do it justice, but it has plagued me on and off for a week, so I was hoping the wisdom of the monks could pull me through.


I admit it, I am Paco.

In reply to Anonymous Data Structures: How Do They Work? by jonjacobmoon

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.