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

next unless $. == $array[$i++];
to
next unless $. == $array[$i]; $i++;
and it should work.

Also, you should really add or die "open: $! to your open statement.

Update: and to eliminate a warning, you may want to replace

next unless $. == $array[$i++]; print OUT $_;
to
next unless $. == $array[$i]; print $_; ++$i < @array or last;