in reply to Perl printing in the wrong order
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.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl printing in the wrong order
by druisgod (Initiate) on Apr 29, 2011 at 13:27 UTC |