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
That puts the regex itself in scalar context, which isn't what you want. Instead, put the regex in list context (to get the number of matches) and put that into scalar context.
my $number = () = $string =~ /\./gi;