You're changing the file name ($ip) in the wrong place, so the first file gets two dates, the last one none, and the remaining get the date (which belongs to the next file) at the bottom...
I.e.,
you have: you want: ------------------------ ------------------------ date date (first file) (first file) ...data... ...data... date ------------------------ ------------------------ date ...data... ...data... date ------------------------ ------------------------ date ...data... ...data... date ------------------------ ------------------------ date ...data... ...data... date ------------------------ ------------------------ date (last file) (last file) ...data... ...data... ------------------------ ------------------------
Move the
$ip=$net.$counter;
to the beginning of the loop:
while ( $counter <= 14 ) { $ip=$net.$counter; ...
in which case you also no longer need the first occurrence before the loop.
(BTW, there's no need to open/close the same file multiple times.)
In reply to Re: Perl printing in the wrong order
by Eliya
in thread Perl printing in the wrong order
by druisgod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |