in reply to General Advice
use strict; use warnings; search(["bobcat", "boomerang", "beer", "bat"], ["-bo"], ["b"]); sub search { my ($data, $negative_criteria, $positive_criteria )= @_; my $re="^(?!" . join("|", map{ s/^-//;$_ }@$negative_criteria) . ") +" . join "|", @$positive_criteria; $re=qr|$re|; my @results = grep { m/$re/ } @$data; for (0..$#results){ print $_+1 . " - $results[$_]\n"; } return \@results; }
"The trouble with the Internet is that it's replacing masturbation as a leisure activity."
-- Patrick Murray
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: General Advice
by yoda54 (Monk) on Jun 27, 2013 at 20:18 UTC |