in reply to set value of a variable to a regexp
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
|
|---|