in reply to Re^2: Appending backslash to a string
in thread Appending backslash to a string

Here is a simple SSCCE showing how to achieve what you have asked for.

use strict; use warnings; use Test::More tests => 1; my $have = 'http://www.myurl.com/me.html'; my $want = 'http:\/\/www.myurl.com\/me.html'; $have =~ s#/#\\/#g; is $have, $want;

Note however that I agree with haukex that under most circumstances the result which you say you want is maybe not so useful and that this does sound rather like an XY Problem.