sub find_eye_shapes { my @key = map( [ split/\s+OR\s+/ ], @_); my @ret; for my $s (get_eye_shapes()) { my $p = get_eye_properties($s) or next; # no properties exists($p->{keywords}) or next; # no keywords property my %h; @h{ split(" ", $p->{keywords}) } = (); my $found = 1; for my $k (@key) { grep(exists($h{$_}), @$k) or $found = 0, last; } push(@ret, $s) if $found; } return @ret; } #### # Get all shapes with keywords: face AND person AND perlhacker my @faces = find_eye_shapes('face', 'person', 'perlhacker'); # Get all shapes with keywords: face AND (person OR animal) my @faces = find_eye_shapes('face', 'person OR animal');