use strict; my $string = 'this is my sting with \ and /slashes. put substing in quotes'; my $substring = 'with \ and /slashes'; print $string; $string =~ s/\Q$substring\E/\"$substring\"/gi; OUTPUT: this is my sting with \ and /slashes. put substing in quotes