1) You need use strict; use warnings;. Each time you go through the loop, you create a new @range_counts. Notice the my within {}. Furthermore, the print uses the global @range_counts, not one of those in which you placed values, since they went out of scope. Put my @range_counts; at the very top.

2) @ranges = ([$i, $j, $k, $m]); create a single element in @ranges. Is that really what you want to do? In your code, $R will always be 0, and for my $R (0..$#ranges) will always loop only once.

3) You spoke of "hash of arrays", yet there are no hashes in that program.

4) I couldn't help but noticing you're reading the same file over and over and over and over again. That's rather innefficient. Especially since you put the contents of the file in an array. Why not populate @file only once?

I can't help you more (and I'm surprised I helped you this much) since you didn't provide a sample input and the desired output for that input.


In reply to Re: folow up to headache with array by ikegami
in thread folow up to headache with array by Anonymous Monk

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.