Think about Loose Coupling | |
PerlMonks |
How can grep search based on text or pattern based on user input?by Russ (Deacon) |
on Dec 02, 2000 at 08:11 UTC ( [id://44553]=perlquestion: print w/replies, xml ) | Need Help?? |
Russ has asked for the wisdom of the Perl Monks concerning the following question:
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. :)
Back to
Seekers of Perl Wisdom
|
|