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
Try this:
my $string = "one.two.three.four"; my ($number) = scalar( @{[ $string=~/\./gi ]} );
It returns 3 for me. By creating a reference to an array the regular expression is evaluated in list context and the @{..} de-references the array reference.
3
@{..}