use warnings; use strict; my $pattern = '1'; my @list = ( 1,2,'a','b',5,1,1,'t'); # In a scalar context grep will return the total times # that the pattern was find in @list # If you use @times = grep(/$pattern/,@list); # @times will contain the pattern it founds in the array # in this case @times will be ( 1 , 1 , 1 ) my $times = grep(/$pattern/,@list); print "The pattern was found $times times";