my @array = qw/some stuff in here/; #instead of: my @matches = grep { /^s/ } @array; #which would give you ("some","stuff"); #you could try something like this: my @indices = grep { $array[ $_ ] =~ /^s/ } 0..$#array; #which would give you (0,1), which are the indices of the array you want. #and then to get matches, you can still do something like: my @matches = @array[ @indices ];