Re: parse search string?

2003-09-02 Thread $Bill Luebkert
Burak Gürsoy wrote:

> I've searched cpan but only found some APIs to several search engines...

And what do you need that's different from what they provide ?

> I want to parse search string and split parameters. like user can put a plus
> sign for wanted words and minus for not-wanted or put single or double
> quotes or some other weird thing etc... if such a module exists I'd like to
> know :)

There is no standard that I know of for search string args.

All CGI args are split at each '&' and starting at the '?'.
EG: ?arg1=val1&arg2=val2

-- 
  ,-/-  __  _  _ $Bill LuebkertMailto:[EMAIL PROTECTED]
 (_/   /  )// //   DBE CollectiblesMailto:[EMAIL PROTECTED]
  / ) /--<  o // //  Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_http://dbecoll.tripod.com/ (My Perl/Lakers stuff)


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: parse search string?

2003-09-02 Thread Hanson, Rob
I don't know of any module that does all of that automatically, but there
are good ways to do it if you feel like learning something new.

Parse::RecDescent is a parser builder.  You supply a grammer (rules), and it
builds a parser that can parse that grammer.

http://www.perl.com/pub/a/2001/06/13/recdecent.html

It guess it all depends on how much time you are willing to invest.  If you
only ever write a parser this one time, Parse::RecDescent is a bad
investment.  If you think you might use it again, it is worth the trouble.

If you want a simpler solution, you might want to look at Lex.  Lex (a
lexer) is the part of a parser(1) that cuts up the input into "tokens".  In
your case a token would be a plus, a minus, and a string.  You would then
loop over each token, deciding what to do.

http://search.cpan.org/author/YVESP/llg-1.07/Lex.en.pod

For a bare bones solution you will want to use some regexes, maybe like
this...

while ($input =~ /([+-])(\w+)/) {
  my $sign = $1;
  my $word = $2;

  # do stuff here
}

Rob

(1) I say "parser", but I mean compiler.  I just didn't want to over
complicate things.

-Original Message-
From: Burak Gürsoy [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 02, 2003 2:18 PM
To: Perl-Win32-Users
Subject: parse search string?


I've searched cpan but only found some APIs to several search engines...

I want to parse search string and split parameters. like user can put a plus
sign for wanted words and minus for not-wanted or put single or double
quotes or some other weird thing etc... if such a module exists I'd like to
know :)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


parse search string?

2003-09-02 Thread Burak Gürsoy
I've searched cpan but only found some APIs to several search engines...

I want to parse search string and split parameters. like user can put a plus
sign for wanted words and minus for not-wanted or put single or double
quotes or some other weird thing etc... if such a module exists I'd like to
know :)

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs