file1: ab gh kl mn op file2: ab, 1234 cd, 2343 ef, 1253 gh, 4543 ij, 2343 kl, 2453 mn, 4753 #### #!/usr/bin/perl # # $file1 = shift; $file2 = shift; $match = 0; open(IN,"$file2") || die "Cannot open file $file2 $!\n"; while(){ chomp($_); $s_line = $_; open(INPUT,"$file1") || die "Cannot open file $file1 $!\n"; while(){ chomp($_); $str = $_; if($s_line =~ /$str/){ $match = 1; } } close(INPUT); if($match == 0){ print "$s_line\n"; } $match = 0; } close(IN);