my $thing_to_find = 'needle'; my @haystack = ('needle', 'hay', 'more hay', 'yet more hay'); my $needle_count = scalar(grep { /^$thing_to_find$/ } @haystack);