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 $_; }