If you want to get all the matches, you need to use list context. One ugly way to do that is:
But if you're just counting a single character, use tr/// because it'll be much faster:my $d = () = ($n =~ /A/g);
my $d = ($n =~ tr/A//);
In reply to Re: how to count matches
by merlyn
in thread how to count matches
by jeanluca
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |