How do I convert UNIX path to DOS path How do I convert UNIX path to DOS path unix unix

How do I convert UNIX path to DOS path


#!/usr/bin/perluse strict; use warnings;use File::Spec::Win32;print File::Spec::Win32->canonpath('C:/My Document/Photo.gif'), "\n";


This is the regular expression

s/\//\\/g


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";