in reply to seek and replace for exceptional characters

You could also change your push line to:

push @newlines, s/\Q$A\E/$B/rg for @lines;
(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.

Update: Add clarification for my 'optional' comment.

--MidLifeXis

Replies are listed 'Best First'.
Re^2: seek and replace for exceptional characters
by semipro (Novice) on Sep 23, 2013 at 17:53 UTC
    Thank you! :-)