Your code looks OK, are you sure the problem isn't with what you're trying to match against?
Try this:
my $re = 'fo+|zzz'; my @matches = grep /$re/, qw/ f fo foo bar foobar zzzz /; print "@matches";
Output:
fo foo foobar zzzz
In reply to Re: set value of a variable to a regexp
by FunkyMonk
in thread set value of a variable to a regexp
by pc2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |