I'm not sure you want to print the line with the asterisks to OUTFILE2, but you know how to get rid of that if you don't. You can even shorten the third print statement by getting rid of the default scalar $_, if you're so inclined.my $index = 0; foreach (@logme) { print "%%%% $index $_ %%%% "; print "################## IN THE LOOP ##########"; print OUTFILE2 $_; print 0UTFILE2 "*********IN_THE_LOOP********"; $index++; } print OUTFILE2 " OUTFILE2_IS_GOOD ";
Iterating through lists is much, much easier with foreach. Love it.
In reply to Re: Question on file I/O
by chromatic
in thread Question on file I/O
by prefect Bob
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |