Thanks you very much kennethk I think your method of looping through an array is better. I am having problems with understanding how the push method is supposed to work. lets say that i have found 10 occurrences of fever and then 20 occurrences of koorts I have declared an array called hit as suggested. but what I am not sure is how will 10 will be added to the first element and 20 as the second element. I am very new to Perl so am just finding my feet. I just realised that each time that each time for for loop is run it will go to the next element and then the number++ is will started again from zero to add up the occurrences of the next element in the array. i have managed to get the push array function and have performed a few example so i can familiarize myself with it. one problem when i run the print statement it only shows the total amount not the sub divided amount for each element is my test correct

In reply to Re^2: to loop through an array by alexlearn
in thread to loop through an array and store each of the subtotals in the elements of another array by alexlearn

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.