in reply to Re: printing specific lines
in thread printing specific lines
This code has a well-hidden bug (or maybe I'm too tired): you always increment $i even if the equalty doesn't stand. Change
tonext unless $. == $array[$i++];
and it should work.next unless $. == $array[$i]; $i++;
Also, you should really add or die "open: $! to your open statement.
Update: and to eliminate a warning, you may want to replace
tonext unless $. == $array[$i++]; print OUT $_;
next unless $. == $array[$i]; print $_; ++$i < @array or last;
|
|---|