An alternative would be to construct the final regex from the parts:
my @parts = qr/this-stuff/; if ($foo_needed) { push @parts, qr/more-stuff/i; }; my $r = join "|", @parts; $r = qr/$r/; # just to be explicit about what the string is supposed t +o contain
In reply to Re: Composing regex's dynamically
by Corion
in thread Composing regex's dynamically
by John M. Dlugosz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |