@array = ("12G","1G30G","13G24G"); for (@array) { $cntr++ if /G/; } print "$cntr\n";