Hi,
How do I construct a regex to count the number of 'a' within a scalar variable 
such as the undermentioned.
One method I can think of is to split the scalar string into a list and then do 
the counting but I just feel that this in not necessary.
Thanks

{
my $string = 'hello there are many a aaa  aaaa here....  a abbb baaaabba a 
please count me if you can.';
$count_a = 0;

@string = split //,$string;
foreach (@string){
    $count_a ++ if /a/;
}
print "There are $count_a a's in \$string\n";
}

Reply via email to