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;
More Related Contents:
- listing directories and sub-directories to an array with path;
- Dynamic array creation in perl [duplicate]
- Store and read hash and array in files in Perl
- Perl array vs list
- In Perl, is there a built in way to compare two arrays for equality?
- Create a multidimesional key of hash from array?
- What does the range method getValues() return and setValues() accept?
- How to check if an element is in an array
- Change values while iterating
- How do I slice an array in Excel VBA?
- Comparing two arrays & get the values which are not common
- Algorithm to find k smallest numbers in array of n items
- How to pass allocatable arrays to subroutines in Fortran
- Automatic array allocation upon assignment in Fortran
- Flatten [Any] Array Swift
- Given an array, find out the next smaller element for each element
- GCC: Array type has incomplete element type
- Using jsonb_set() for updating specific jsonb array value
- Faster way of using Sumifs()
- Setting arrays in Firebase using Firebase console
- Can I use Perl regular expressions to match balanced text?
- How do I perform a Perl substitution on a string while keeping the original?
- How can I parse quoted CSV in Perl with a regex?
- Subscript out of range error with an array – no idea why?
- Underscore.js groupBy multiple values
- How to escape dollar sign ($) in a string using perl regex
- How do I remove elements at a set of indices in a vector in MATLAB?
- How to forward functions with variadic parameters?
- How do I Merge two Arrays in VBA?
- jq: recursively merge objects and concatenate arrays