in reply to Length of first captured match
That's not true. length() imposes scalar context on its argument, so the pattern match happens in scalar context and returns "1" on success and "" on failure. Thus, you're getting length(1), which is 1, not "length of the number in the number of elements", because "number of elements" is not what the regex is returning.my $x = 'abc12345'; my $length = length ($x =~ /(\d+)$/); # returns 1, the length of the number in the number of elements
|
|---|