L
Long Li
Hi,
I want to calculate the number of match occurrences, for examples,
$string = "abcdabcd";
@a = $string =~ m/a/g;
$num_a = @a;
However, I do not want to use the array "@a" because I do not care
that array, espcially "$string" is very large and include many "a", I
just want to know the number of "a" occurrences. I tried
$num_a = $string =~ m/(a)/g;
or
$num_a = ( $string =~ m/a/g );
They both did not work. Please give me some suggestions, thanks.
I want to calculate the number of match occurrences, for examples,
$string = "abcdabcd";
@a = $string =~ m/a/g;
$num_a = @a;
However, I do not want to use the array "@a" because I do not care
that array, espcially "$string" is very large and include many "a", I
just want to know the number of "a" occurrences. I tried
$num_a = $string =~ m/(a)/g;
or
$num_a = ( $string =~ m/a/g );
They both did not work. Please give me some suggestions, thanks.