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
except that toolic's reply demonstrates that it does work and the perlsyn docs include a table in the 'Smart matching in detail' section that includes:
$a $b Type of Match Implied Matching Code ====== ===== ===================== ============= ... Any Array match against an array element[3] grep $a ~~ $_, @$b ...
which clearly shows that an element by element smart match is performed, so an array of Regexs should work as the OP expects (and as toolic confirms). My best guess is that the OP is using 10.0 which introduced the smart match operator and a pile of bugs. 10.1 and later fixes a pile of smart match related bugs.
The brian d foy post linked by the OP is rather more explicit that the technique works than the Perl docs and, given the author, is fairly likely to be reliable.
|
|---|