Print all non-matching items in Perl

170 Views Asked by At

I have a perl script that compares text from two files. The files on most days should be exactly the same, but if for some reason some of the text in the file changes I want the script to print out all the text that is not exactly the same as in the other folder. I want it to print out the differences between the files.

if($atext !~m/$btext/){
print $1;
}

That is what I currently have but it is giving me the error, "Use of uninitialized value $1 in print at blah blah blah".

1

There are 1 best solutions below

0
On BEST ANSWER

How about using something like Text::Diff instead of building your own?

See the comments for the explanation about how you didn't use a capture group to set $1.