How do I convert UNIX path to DOS path
First off, you do not normally need to do that mapping unless you are going to invoke something via cmd.exe
; the Windows API is perfectly happy with slashes instead of backslashes in file names (but cmd.exe
insists that slash starts an option).
Then, the direct answer to your question is perhaps:
my $file = "C:/My Documents/Photo.gif";$file =~ s{/}{\\}g;print "$file\n";