>perl -wMstrict -le "my @regexes = qw( foo b[a-z] ); my $string = 'fooey'; if ( grep { $string =~ /$_/ and return 1 } @regexes ) { print qq($string matched some regex); } " Can't return outside a subroutine at -e line 1. >perl -wMstrict -le "use List::MoreUtils 'any'; my @regexes = qw( foo b[a-z] ); my $string = 'fooey'; if ( any { $string =~ /$_/ } @regexes ) { print qq($string matched some regex); } " fooey matched some regex
In reply to Re^2: Matching an array of regexes (grep in reverse)
by AnomalousMonk
in thread Matching an array of regexes (grep in reverse)
by raymor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |