$newpat = '_$1_';
That needs to be in double-quotes, or it gets interpreted literally.
That's the problem with the sample code, at least. It sounds like your production code might be different, since you mention the patterns are user-supplied. Do you have a sample of that?
In reply to Re: s/// ignoring subexpressions with variable replacement patterns
by mattriff
in thread s/// ignoring subexpressions with variable replacement patterns
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |