|Keep It Simple, Stupid|
How can grep search based on text or pattern based on user input?by Russ (Deacon)
|on Dec 02, 2000 at 08:11 UTC||Need Help??|
Russ has asked for the
wisdom of the Perl Monks concerning the following question:
This was moved from Categorized Questions and Answers.
Please do not vote for this node. It will affect the wrong user.
Thank You -- Q&AEditors
I've got a CGI that accepts a single form field (name=searchtext) which I put into $searchtext. I'd like to offer the un-Perl-knowledgeable user to simply enter a word with * wildcards like any normal search, but at the same time offer the Perl-knowledgeable user the ability to enter a pattern.
I'm assuming that the un-Perl will enter something like "surf*g" and the Perl user will enter something like "/surf\w*/i" or similar. (I'm assuming that all searches by the un-Perl are case insensitive.)
Here's what I have so far:
Problem is, this doesn't work. And even if it did, I'm sure it's nowhere close to being the most efficient code around. Any suggestions? Thanks. :)