in reply to Opening files in a loop

Either the code you posted is different in some details from the code you're running, or else the running code never actually produces any output that includes "Certification is ..."

The problem would be easy to spot if you used proper indenting in your "if", "elsif", "else", "for" and "while" blocks. Here's how the last chunk of your code looks when properly indented (with some condensing and removal of unnecessary stuff to make it shorter):

if ($lines <= 0) { #print "has no records at this time."; print "<p\/><hr><p\/>"; while ($lines >=1) { $certification = shift(@data); print "Certification is $certification on "; my $number = shift (@data); $month = $mon [$number-1]; $day = shift (@data); $year = shift(@data); $mo_yr = shift(@data); print "$month $day $year $mo_yr<p/><HR>"; $lines--; } }
When the "if" and "while" blocks are bracketed that way, the condition for the "while" loop can never be met. Either remove the initial "if" statement there, or else move the "while" block outside the "if" block. In either case, look for a text editor that has a suitable mode for programming, and will do indentation for you (emacs and vi are the most popular examples, there are others).

Replies are listed 'Best First'.
Re^2: Opening files in a loop
by loop362 (Pilgrim) on Jun 06, 2005 at 16:13 UTC
    Aloha,

    Sorry it takes so long for me to respond. I appreciate and will endevor to try and follow the indention convention. Your code works (as mine did) but after a lot of study, yours makes more sense.

    Mahalo. JWG