Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: Opening and closing files in loopby Corion (Patriarch) |
on Oct 22, 2012 at 08:33 UTC ( [id://1000290]=note: print w/replies, xml ) | Need Help?? |
You don't show the value(s) of $i and $max, so maybe there is a simple reason why your loop only gets run once. Personally, I would change the coding style in two places to avoid nasty errors: First, I would not use the C-style for construct but iterate over a range. I'd also use a lexical $i to avoid clobbering the loop counter through side-effects:
Second, I would avoid using select for choosing the active output handle and print to the filehandles directly:
While rewriting your code to the new idiom, I saw that you seem to be running without warnings. As soon as you add use warnings; to the top of your script, or add -w to the Perl invocation, Perl will tell you what is going wrong.
In Section
Seekers of Perl Wisdom
|
|