#!/usr/bin/perl -w # literally, ALL this will do is show you whether the # string you're searching for is in both files. # you might want to know line numbers, too, but this won't # do it without modification. use strict; # get variable, and filenames from wherever ... if (in_file($pattern, $filename1) && in_file($pattern, $filename2) ) { print "Found $pattern in both $filename1 and $filename2\n"; } else { print "$pattern not found in both $filename1 and $filename2.\n"; } sub in_file { my ($pattern, $filename) = @_; open FILE, $filename or die "Can't open $filename: $!\n"; my $found =0; while () { # set found to a true value and exit the loop # if we find the pattern in the current line. $found=1, last if /$pattern/; } close FILE; $found; }