in reply to Nested greps w/ Perl
For a naive reading for your spec, it'd probably be something like:
though if you were committed to chained greps, you could writemy $count = grep /\Q$SEARCH_TERM\E/ && /Z/, @C_LOC_ARRAY;
You might also get a speed boost by using index, depending on your particular need.my $count = grep /Z/, grep /\Q$SEARCH_TERM\E/, @C_LOC_ARRAY;
Depending on the type of search you are trying to perform, I would say a database might be a cleaner solution; an in-memory SQLite database would be very fast (though have a big footprint) and a file-based database would allow you to only index once.
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Nested greps w/ Perl
by wackattack (Sexton) on Dec 19, 2016 at 22:06 UTC | |
by kennethk (Abbot) on Dec 19, 2016 at 22:37 UTC | |
by SimonPratt (Friar) on Dec 20, 2016 at 15:21 UTC | |
by wackattack (Sexton) on Dec 20, 2016 at 16:21 UTC | |
by kennethk (Abbot) on Dec 20, 2016 at 17:07 UTC | |
by wackattack (Sexton) on Dec 20, 2016 at 22:44 UTC | |
by BrowserUk (Patriarch) on Dec 20, 2016 at 18:33 UTC | |
|
Re^2: Nested greps w/ Perl
by wackattack (Sexton) on Dec 19, 2016 at 22:29 UTC | |
by kennethk (Abbot) on Dec 19, 2016 at 22:45 UTC | |
by Laurent_R (Canon) on Dec 19, 2016 at 23:15 UTC | |
by wackattack (Sexton) on Dec 20, 2016 at 16:26 UTC | |
by Laurent_R (Canon) on Dec 20, 2016 at 19:02 UTC | |
by BrowserUk (Patriarch) on Dec 19, 2016 at 23:35 UTC |