in reply to Printing specific line numbers

The following method stores the lines you wish to print in a hash as an action tabletm. This allows for a fairly simple approach to reading the second text file, and deciding line by line whether to print or not. This method is fairly efficient:

use strict; use warnings; my %find; open INDEX, '<', shift( @ARGV ) or die $!; while( <INDEX> ) { @find{ $_ .. $_ + 2 } = (); } close INDEX; while( <> ) { next unless exists $find{$.}; print $_; delete $find{$.}; last unless keys %find; }

Advantages:

The above code is "one liner friendly", and can be expressed like this:

perl -ne "BEGIN{open I, '<', shift(@ARGV); while(<I>){ @find{$_ .. $_+ +2}=();}} next unless exists $find{$.}; print; delete $find{$.} last u +nless keys %find;"

Dave