Sorry about the badly chosen subject.

I want to search in a database for values belonging to a key.
The key can be one word, or several words.
I get the key in a string, but it is not needed that the whole string
is the key.
You may ask: "what is the perl language?"
The key may be "the perl language"
The most right word in the string is most important.
When I have a key called "language" for example I should get that.
I already chopped off the question mark.

The key is looked up in a database, as soon a key is found the string
will no longer be processed. The lookup function works perfectly so I
don't have to check that.

I tried to do the following, but that can't be right and that doesn't
work (code is simplified):
my $msg="what is the perl language?";
my @words=split(/ /, $msg);
foreach my $word ( @words ) # check if something is asked about this subject
 {
   next unless $word=~/\?$/;
   $word=~ s/\?//g;
   for ( my $i=0; $i <4; $i++  )
   {
     print "$i is I\n";
     my ( $searchword ) = $msg=~ s/((\w+){$i,}\s$word)\?$//;
     my $found=&check_learned($searchword);
     {
        if ( $found  && $found->{what})
         {
           blah();
           last;
          }
      }
    }
}

I don't see a better option, so I can't find out a working option ;-)
I am sure there is someone who is more bright than me.

Wijnand
--
No virus was found in this outgoing message as I didn't bother looking.
This is not an automated signature. I type this in to the bottom of every
message.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to