$txt = ' \*/ '; $txt =~s/\\/\\\\/g; # what I expected ' \\*/ '; print $txt;