I am trying to loop through an array were the first element is either a 3, 4, or 7 the second value is any number between 1 and 2048.
The number of rows in the array is random.
example of array:
3 200
4 50
3 100
3 100
3 100
4 50
4 25
The first rows where [element 0 = 3] need to have [element 1] added together and then set equal to a variable.
The first set of rows where [element 0 = 4] need to have [element1] added together and set equal to a variable.
Using the example array the value of the variables should be ele3 = 200 and ele4 = 50.
Then I need to call another subroutine that process those variables
. Here is where I get stuck
I need to go back to that loop and start at the next row in the array and find all the [element 0 = 3] add up the [element 1] set them equal to same variable as the before ele3.
Find all the [element 0] = 4 and add up the [elements 1] and set it equal to the same varable ele4 and pass them to the sub routine.
Using the example array the value of the variables (the second time) should be ele3 = 300 and ele4 = 75.
If the the value of [element 0 = 7] it should just report it as an error and fail.

edited: Tue Sep 10 02:48:38 2002 by jeffa - s/\[/[/g


In reply to stoping and restarting a loop by mnlight

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.