my $switch = 'quick'; my @array = qw(the quick fox jumped over the lazy dog); my %matches = map {$_,1} @array; my $match = exists $matches{ $switch } ? 1 : 0; print $match; #### my $match = grep { /$switch/ } @array;