You could also change your push line to:
(the \E is optional in this case, as the quoted variable is the last thing in the RE) to handle the quotemeta within the search/replace itself. See perlre for more information.push @newlines, s/\Q$A\E/$B/rg for @lines;
Update: Add clarification for my 'optional' comment.
--MidLifeXis
In reply to Re: seek and replace for exceptional characters
by MidLifeXis
in thread seek and replace for exceptional characters
by semipro
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |