use strict; use warnings; my %fruit = ( 'apple' => ['red','green'], 'kiwi' => 'green', 'banana' => 'yellow', ); for my $search ("green","red" ){ my @matches = grep { $search ~~ $fruit{$_} } keys %fruit; print "\n\n Matches for <$search> = @matches\n\n"; } #### C:/Strawberry/perl/bin\perl.exe -w d:/tmp/pm/smartmatch.pl Smartmatch is experimental at d:/tmp/pm/smartmatch.pl line 12. Matches for = kiwi apple Matches for = apple Compilation finished at Tue Nov 9 22:04:30 #### my %fruit = ( 'apple' => ['red','green'], 'kiwi' => ['green'], 'banana' => ['yellow'], );