my (@names) = ( ... ); sub search { my (@search_keywords) = split (/\s+/, shift); my ($match_code) = "sub{".join('&&', map { "/\Q$_\E/" } @search_keywords)."}"; my ($match_func) = eval $match_code; return grep { &$match_func() } (@names); } my (@results) = search ("the fried potato king");