It then occurred to me that the code won't run if the regexp has no capture groups!
It will run. The match returns 1 in such circumstances.
$ perl -Mv5.14 -e'if ( my @m = "b" =~ /(a)/ ) { say "@m"; }' $ perl -Mv5.14 -e'if ( my @m = "a" =~ /(a)/ ) { say "@m"; }' a $ perl -Mv5.14 -e'if ( my @m = "b" =~ /a/ ) { say "@m"; }' $ perl -Mv5.14 -e'if ( my @m = "a" =~ /a/ ) { say "@m"; }' 1
In reply to Re: How to know that a regexp matched, and get its capture groups?
by ikegami
in thread How to know that a regexp matched, and get its capture groups?
by Anonymous Monk
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |