Hello,

I am currently working on a search-eingine for .txt files
I am searching for $word in each .txt file.

Now of course the ability to search for 2 words in the document, must become 
possible. Does any of you have an idea how to compare two hashes for the same entries ?

I will show you :

# ------------------------
 find(\&files, $directory);

 # ---
 sub files {

   my $file = $File::Find::name || shift;
    next if($file =~ "ref.txt");
    if ( $file =~ /\.txt$/ ) {
      open (FILE, $file);
       while (<FILE>)  {
         $_ = lc ;
          if(m/$word/) { $results{$file}= $_; }
       } # End while
    }
 } # end sub files
 
In here I will just have to build in a second :
if(m/$second/) { $other{$file}= $_; }

After this I change the lines to become html-minded the way I want it. I can
of course do the same for %other and push it into @insecond.

sub subst {
   for (sort keys %results) {
     s!/[^/]*\z!!;
     my $link = '/' . (split (/\//, $_, 4))[-1];
     ($href = $_) =~ s(^.*/) ();
     push @in, "<tr><td>$href &nbsp </td><td>&nbsp <a 
href=${index}?load=y?dir=$_?href=$href>$link</a>&nbsp </td></tr>";
   }
 } # End sub subst


Make @in and @insecond uniq :

sub uniq {
   my %saw;
   @out = grep(!$saw{$_}++, @in);
 } # End sub uniq

And then of course print it :

print "$_" foreach @out;

But how do I print only those entries that excist both in @out and @outsecond ??

So in short :
I want to match 2 words within .txt documents, if the document contains BOTH words
I'dd like to print it.


Your help is much apreciated !!


Regs David

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to