As per perlop
, in list context, a matching operator m//
with a regex that has a capture group and a /g
modifier will return a list of captures:
my $str = "8a9b0c"; my @res = ($str =~ m/(\d)/g); print @res;
# Prints "8 9 0"
However, I can't find in either perlop
or prelre
any mention of why substitution operator will instead - even in list context - return the number of captures:
my $str = "8a9b0c"; my @res = ($str =~ s/(\d)//g); print "@res\n"
prints "3"
Why and where is that behavior documented?