in reply to Re: string/array smart match regex failing me
in thread string/array smart match regex failing me
You cannot use ~~ to match a given string with an array of patterns.
Yes you can. From perlsyn of 5.10.1, 5.12.0 and 5.12.2, the first matching case is
Any ~~ Array match against an array element grep $a ~~ $_, @$b
which repeatedly does
Any ~~ Regex pattern match $a =~ /$b/
Example:
use feature qw( say ); my @pats = map qr/$_/, qw( a c ); for (qw( aaa bbb ccc ddd )) { say if $_ ~~ @pats; }
aaa ccc
I didn't check the 5.10.0 docs since smart matching underwent major fixes in 5.10.1.
|
|---|