#!/usr/bin/perl -w use strict; my $infile = 'c:\\hl7file2.txt'; my ( $yr, $mo, $dy ) = (localtime)[5,4,3]; my $outfile = sprintf( "%04d%02d%02d.txt",$yr+1900,$mo+1,$dy ); my $counter; open IN, "<$infile" or die "Couldn't open $infile, $!"; open OUT,">$outfile" or die "Couldn't open $outfile, $!"; # $counter++; # print $counter; my @finds = qw( 00000 00001 00002 00003 00004 76370 76375 76950 77403 77404 77406 77407 77408 77409 77411 77412 77413 77414 77416 77418 77370 77336 77417 ); # my $finds_re = join '|', map { quotemeta }@finds; my $finds_re = '\b' . join( '|', map { quotemeta } @finds ) . '\b'; $finds_re = qr/$finds_re/; # print $finds_re; while() { next if m/$finds_re/; print OUT; } close IN;