my @foo; foreach (@a) { push @foo,$_ if ($_ eq "q"); } print scalar @foo;