#untested but should work $dt =~ y{/}{\\/}; #or $dt =~ tr{/}{\\/};