Suppose I have:
my $string = \"one.two.three.four\";
How should I play with context to get the number of times the pattern found a match (3
I think the clearest way to describe this would be to avoid the instant-cast to scalar. First assign to an array, and then use that array in scalar context. That's basically what the = () = idiom will do, but without the (rarely used) idiom:
my $string = "one.two.three.four";
my @count = $string =~ /\./g;
print scalar @count;