On Thu, 7 May 2020 12:01:58 +0200, Michael Herger <slim (AT) herger (DOT) net> wrote:
> > $x =~ s/\(id\)/\Q$id\E/g;
>
> Heh... I failed! And actually was surprised to see that these would work
> in the replacement expression...
>
Why surprised? \Q and \E are string meta characters and identical to
quotemeta(...).
The fact that they are mostly used in the match part of regexes doesn't
mean they are not useful elsewhere :) .
-- Johan
> > $x =~ s/\(id\)/\Q$id\E/g;
>
> Heh... I failed! And actually was surprised to see that these would work
> in the replacement expression...
>
Why surprised? \Q and \E are string meta characters and identical to
quotemeta(...).
The fact that they are mostly used in the match part of regexes doesn't
mean they are not useful elsewhere :) .
-- Johan