in reply to How can grep search based on text or pattern based on user input?
foreach (sort {$a <=> $b} grep /$searchtext/, grep !/^#/, <STUFF>) {
That means that you'll have to strip off the slashes on a user-supplied regex, and not add them in on the other option.
As for efficiency, it's not too bad. I'd get rid of the double grep though, by slurping everything in at once (if it's a small file), skipping commented lines, or rewriting the loop condition somewhat.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: How can grep search based on text or pattern based on user input?
by gryphon (Abbot) on Dec 04, 2000 at 22:18 UTC | |
by chromatic (Archbishop) on Dec 04, 2000 at 22:49 UTC | |
by chipmunk (Parson) on Dec 04, 2000 at 23:02 UTC |