in reply to Re^7: simple array question
in thread simple array question

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.