> So in short :
> I want to match 2 words within .txt documents, if the document contains BOTH words
>I'dd like to print it.
I am assuming you mean strings, whereas a word would be surrounded by space
ala: /\s$word\s/. To rephrase what you want a little, you want to track how many times
string one is found in a file, track how many times string two is found in the same
file, and keep the file only if both strings are found in the file.
while (<INFILE>) {
if ($_ =~ /$string1/i) {
++$found{$file}{1};
}
if ($_ =~ /$string2/i) {
++$found{$file}{2};
}
}
if ( ($found{$file}{1} >= 1) && ($found{$file}{2} >= 1) ) {
push(@matches, $file);
}
Each filename must be unique, since they are used as the keys for the hash.
=-= Robert T.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]