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