use FileHandle::Deluxe; $fh = FileHandle::Deluxe->new("library.txt", allow_insecure_code=>1, auto_chomp=>1); my $library = $fh->contents; open (DATA, "input.txt"); while () { chomp($_); $entry = $_; if ($library =~ /$entry/i) { print "found - $entry\n"; } else { print "new - $entry\n"; } }