toolic has identified the basic problem. These ramblings are for your consideration (in light of the self-characterization in your home node):

You appear to be passing variables --$count and $newPrices{key} -- into getFiles() as arguments to the call. By doing it that way, your sub changes their values in main and in the sub. For example, if the first file has three lines and the second has four, and if the value of $count in main is 0 on entry to the sub, its value will be 7 when you return from the sub. That's probably a non-issue in the particular case, but it's a behavior of which you want to be aware.

You've also written a sub with no explicit return which means the sub may do something you're not expecting, as explained in perlsub:

"If no "return" is found and if the last statement is an expression, its value is returned."

All in all, then, I commend a close reading of perlsub re return and also with special attention to the explanation of passing variables by reference.

Update: clarifiation, p2, sentence 2 and fixed markup.


In reply to Re: Opening an array of file names by ww
in thread Opening an array of file names by tnyflmngs

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.