Hmmmm ... how about a closure? :)
my @regex = ( 'foo', 'b[a-z]' ); my $string = 'foo'; my $inc = inc(); &$inc( $string, $_ ) for @regex; print &$inc(); sub inc { my $count = 0; return sub { return $count unless @_; $count++ if $_[0] =~ /$_[1]/; }; }
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to Re: Matching an array of regexes (grep in reverse)
by jeffa
in thread Matching an array of regexes (grep in reverse)
by raymor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |