in reply to @arrys & Non exact searches.
This will return all records that match all terms. For a version that matches any, switch the '&&' in the join() to be '||' instead.my (@names) = ( ... ); sub search { my (@search_keywords) = split (/\s+/, shift); my ($match_code) = "sub{".join('&&', map { "/\Q$_\E/" } @searc +h_keywords)."}"; my ($match_func) = eval $match_code; return grep { &$match_func() } (@names); } my (@results) = search ("the fried potato king");
|
---|