Hi Robert,
Looks good, but doens't work :)
The if-statements work fine within the while-loop.
After that you do something I realy don't get and my perl either :)
It start complaining :
Use of uninitialized value in numeric ge (>=) at /user/web/apache/cgi-bin/IPlib/1 line
88, <FILE> line 471
Any idea, what goes wrong ??
Maybe you can give me a litlle more explenation ?? Hope you have the time for it.
B.T.W. @matches is completely empty.
Regs David
# -----------------------
>
> > 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]