in reply to Re: Two loops
in thread Two loops

Aloha,
I read all the data (from a file) into an array. There are 5 lines to each set. (I actually will only print 4) So I want to read 5 lines then increment then look and see if there is 5 more if there are read and print them, until I've exausted the file (which won't be too big). Somehow I get four lines, two with valid data and two more sets with only one line in each set and data that really looks weird.

Mahalo, for your time. Joseph W. Guillaume

Replies are listed 'Best First'.
Re^3: Two loops
by gsiems (Deacon) on May 27, 2005 at 13:26 UTC
    I'm not sure I get what it is you're trying to do... However, to the extent that I think I know, try the following:
    for (1 .. int(scalar @data / 5)) { my $certification = shift(@data); my $number = shift(@data); my $month = $mon[$number - 1]; my $day = shift(@data); my $year = shift(@data); my $mo_yr = shift(@data); print "Certification is $certification on $month $day $year <p\/><H +R>\n"; }

    I'm guessing that there is a better way of doing this, but without knowing what the rest of the script is doing...

    --greg