in reply to how to count matches
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//);
|
|---|