I was perusing perlfaq4
during my lunch break today and came across the topic "How do I handle linked lists?" The first sentence of the answer reads in part as follows: "In general, you usually don't need a linked list in Perl..." I did a double take and a silent "Hoo-aahh!" I have rather nasty memories of trying to follow material on linked lists in certain algorithm texts years ago, so realizing that a programming language (i.e. Perl) can be widely accepted without linked lists as a feature was gratifying and enlightening.
Another quote from the faq: "If you really, really wanted, you could use structures as described in perldsc
and do just what the algorithm book tells you to do...but again, Perl's built-in are virtually always good enough." To me, this is another feature that pushes Perl to the top of my list when considering languages to use for coding projects.
Have any monks implemented linked-list structures in their Perl code, and if so did your performance improvements outweigh the additional complexity of the code?
Update: The node Shift, Pop, Unshift and Push with Impunity!
showed up in the
Selected Best Nodes
and based on my reading of it makes me comfortable that Perl is very efficient at taking care of the kind of work that linked-list code might otherwise be needed to do such as demerphq
describes in his reply
in this thread.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
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:
Outside of code tags, you may need to use entities for some characters:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||