in reply to comparing 2 files problem

If you don't need to know where on what line in file2 a line from file1 was used, then I would use something like this:
open (F1, "<file1.txt"); open (F2, "<file2.txt"); my $file2; { local $/; $file2 = <F2>; } while (<F1>) { print "Line $. not found.", unless ($file2 =~ /^$_/m); } close (F1); close (F2);

This will put all the content of file2 in a simple scalar, and then check if the line occures by using a regex.

Replies are listed 'Best First'.
Re^2: comparing 2 files problem
by ww (Archbishop) on Sep 08, 2004 at 17:13 UTC
    AM's suggestion works for many cases but if the text in your files contains regex metachars, you'll need to tweak the regex a bit.

    For example, if you had a reference to C++ in your lines, and you use warnings (obligatory warning: you should!), then you'll get a warning about nested quantifiers.