I often find a different tradeoff from you.

Like you I agree that if you want to start accessing things by index, a hash is better than an array. Named keys are easier to maintain and less susceptible to breakage than indexes. Indeed just being able to give things meaningful names is a big enough win that I often dump @_ into a hash and start processing that instead of using arrays.

That said, I usually prefer to arrange through basic array operations (shift, unshift, pop and push) along with Perl's native looping operations and generally list-oriented goodness to never care what the index is. If that is plausible then arrays win hands down in my books. They are faster. Easier to manipulate. Less room for error. Less typing.

And for large files I am likely to see if there is a stream-oriented approach. Why have to read the whole thing in to start processing? (While I don't generally deal with terabytes of data, I have friends who do and they really care about this.)

So I am a bit of a chameleon. There are problems which each is right for and I switch between them often and easily.


In reply to Re (tilly) 3: Reading file into a numbered hash by tilly
in thread Reading file into a numbered hash by KM

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.