This is going to be a lot more answer than you are looking for but as you are in a cross-platform situation I thought I'd share what I have found to be a very re-usable format. I'm in a situation where CPAN is difficult to utilize effectively in our organization, so I created a module I called OSify.pm. In it I created common OS commands OSrecursive copy, OSmkdir, etc and centralized their logic, It has made it so I can code for DOS, linux, and Solaris with the same commands easily, and can be quickly extended to other OS's as required. The following is just the OSPath() that takes care of the delimiter issue, but using the general approach it's easy to adapt to any given command.
sub OSpath {
$_ = $_[0];
debug( "Recieved path as\n $_\n", 0 );
if ( $^O =~ /mswin/i ) {
# Everywhere you find a forward back slash replace it with
# two backslashes
if ( /(\/|\\\w)/ ) {
s/(\/|\\)/\\\\/g;
}
# Incase we've created four backslashes in a row
# reduceit back to one
if ( /(\\)(\\)(\\)(\\)/ ) {
s/\\\\\\\\/\\\\/g;
}
# Have to make sure there is only 1 slash after a drive letter
if ( /(\:\\\\).*/ ) {
s/$1/\:\\/;
}
} elsif ( $^O =~ /solaris/i ) {
s/\\/\//g;
if ( $_ =~ /.*\/(.*\s.*)\/.*/ ) {
my $spacedDir = $1;
unless ( $spacedDir =~ /"/ ) {
$_ =~ s/$1/"$spacedDir"/g;
}
}
} else {
print "Platform $^O is not currently supported\n";
}
debug( "Returning path as\n $_\n", 0 );
return $_;
}