in reply to General Advice
G'day yoda54,
Try to match shorter patterns before longer ones. While your example only shows single items for your positive and negative criteria, your code suggests multiple items are possible. You haven't indicated the source of the criteria but, if qw{book and lots of other patterns then b} was valid positive criteria, you'd fail to match "book" in any of the $data items only to later successfully match "b" in all of them.
... join '|' => sort { length $a <=> length $b } @$xxxxxx_criteria;
You've shown interpolating double quotes in many places where you don't actually want to interpolate anything. They may not be an issue in your minimal example; however, consider what happens if you're searching for, say, email addresses:
... "whoever@example.com" ... # Oops!
If the items in your criteria lists are mutually exclusive, consider wrapping your alternations in (?> ... ) to avoid backtracking. See perlre - Extended Patterns and perlre - Backtracking.
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: General Advice
by yoda54 (Monk) on Jun 27, 2013 at 20:19 UTC |