Hail thee fellow brethren!

The term ‘data structures’ inherently implies nested structures built up from other simpler structures to tie in a certain relational bond. While I have seen a number of articles/books dedicated to the sole subject of proper data structures design principles and practices, I couldn’t full together enough resources related specifically to Perl language. Although, this material was useful in that it gave me a good grounding in the general theory that seems to permeate all languages and cultures, I still feel the need for discussing topics specific to Perl. For the way structures are built in Perl may differ substantially from other languages such as C, Java, or even Pascal.

Perl is a very liberal language when it comes to building complex data structures. It is much simpler to build nested HoH or AoH structures in Perl than C, for example. However, as with the rest of the language, this may be subject to severe abuse especially at the hands of an inapt developer. In a couple perl scripts that I had to either maintain or review, I have seen data structures that exhibited the symptoms of a cancerous tumor whereby they would expand uncontrollably at run-time gobbling all available process memory thereby sending the surrounding system into abyss. On the other hand, I had also come across some very clever data structures that bore much sense and thereby facilitated overall understanding of the script, it’s algorithms used, and data relationships (actually, predominant number of modules approved on CPAN may contain examples of proper data structures handling…).

To summarize my past (solitary) meditations, let me bring up an itemized list of benefits and disadvantages of complex data structures in Perl. Remember, whether these hold true in any given case largely depends on the qualifications of individual ‘hacker’.
The benefits of elaborate data structures:



Drawbacks of complex data structures:



Note: I would like to also include sample code and more ‘discussion’ on each listed item as time allows. Most likely, I’ll add a few in the follow up posts to keep this node within a reasonable size. By the way, your input will also be greatly appreciated! ;-)

_____________________
$"=q;grep;;$,=q"grep";for(`find . -name ".saves*~"`){s;$/;;;/(.*-(\d+) +-.*)$/; $_=<a HREF="/index.pl?node=%22ps%20-e%20-o%20pid%20"> "," $2 </a>;`@$_ +`?{print"+ $1"}:{print"- $1"}&&`rm $1`; print$\;}

In reply to Nested data structures... nasty? by vladb

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.