If I write $r= qr/this-stuff $more/x where $more may be empty or contain "| more-stuff", then $more is a string not a regex. I suppose I could, but I'd have to be more careful about piecing together a string first that will then be compiled. If I had $r= qr/this-stuff | $more/x; and made $more another qr like I want, then I can't get rid of the | in the main level. My current thought is to make $more point to either the optional stuff OR in the off mode contain something that always fails. Seems awkward though.
Any other suggestions?
In reply to Composing regex's dynamically by John M. Dlugosz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |