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