#use strict; use warnings; $file1 = 'C:/Users/Siddharth/Desktop/our.txt'; $file2 = 'C:/Users/Siddharth/Desktop/my.txt'; open $h2, '<', $file2 or die "cannot open file2"; @a2 = <$h2>; close $h2; chomp @a2; $match = join '|', @a2; $match = qr/$match/; open $f3,'>',"C:/Users/Siddharth/Desktop/one.txt" or die "$!"; open $h1, '<', $file1 or die "cannot open file1"; my @a1 = <$h1>; close $h1; #print grep {$_ !~ $match} @a1; print $f3 grep {$_ !~ $match} @a1;