#!/usr/bin/perl -w use strict; my $infile = 'c:/RX_Q.008'; my $outfile = 'c:/testfile.txt'; open IN, "<$infile" or die "Couldn't open $infile, $!"; open OUT,">$outfile" or die "Couldn't open $outfile, $!"; my @finds = qw( 77403 77404 77406 77407 77408 77409 77411 77412 77413 77414 77416 77418 ); my $finds_re = join '|', map { quotemeta }@finds; $finds_re = qr/$finds_re/; while() { next if m/$finds_re/; print OUT; } close IN;