perl code can be so compact I can have trouble decoding it.
Yes, sometimes you can see some incredibly cryptic looking Perl code! That doesn't mean that it is "good code", even if the code actually does work. Space things out and certainly don't hesitate to use multiple small steps instead of one complex one. Fewer characters of code does not necessarily result in faster code, actually the inverse is often true!

Besides of course producing working code, the single most important goal is to write code that is clearly understandable. It is more likely to "work" and will certainly be easier to modify later. Save the super tricky looking stuff for some obfuscated code contest.

Right from the start, you are tackling some difficult concepts with data structures that contain references to other data structures. There is a certain amount of de-referencing syntax that you will have to learn, but it is actually easier than equivalent implementations in C.

Perl can be a wonderfully expressive language that is easy to read, often much, much easier to read than the equivalent C code. Or it can look like a cryptic mess.

When I write code using list slice, I usually order the names of the variables on the left hand side to correspond to the order that they will be used in the subsequent code. I adjust the index values to the slice accordingly. List slice can be used with the various CSV parsers, well actually anything that produces a list. This is an important technique to clarify and un-clutter the code. This avoids all these declarations like "DEFINE Date 3", etc.


In reply to Re^8: simple array question by Marshall
in thread simple array question by tw

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.