Two tiny nitbits:
  1. It's a good thing to put the local in a block (so ++), but with unexperienced users (the poster) it may be nice to note what it does. Well, the {local....} BLOCK restricts the scope of local to that block. So after the block, the $/ has it's original value (the line separator). One can read more about these and other vars in perlvar.
  2. (Really tiny)The foreach was copied from the original post (and it works), but here is a for more precise. A foreach loop is used to change the contents of an array, for is not. So for reading in a file, I would recommend for. A typical use for foreach:
    @array = 0..100; foreach $item (@array){ $item += 10 if $item <100; } print join "\n", @array; #prints the numbers 10 to 109 and 100
    You can read more about it in for vs foreach.
Hope this helps,

Jeroen
"We are not alone"(FZ)
Update: For clarity, for and foreach *are* synonyms. It's just a matter of convention....


In reply to Re: Re: hashes of arrays by jeroenes
in thread hashes of arrays by mbond

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.