jesuashok has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re: changing the path name to unix style.
by ikegami (Patriarch) on Dec 13, 2006 at 07:15 UTC
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: changing the path name to unix style.
by nimdokk (Vicar) on Dec 13, 2006 at 12:57 UTC
    I don't know as it is a "builtin" but you could use File::Spec to achieve the same results.

    use strict; use File::Spec; use File::Spec::Unix; my $path = "C:\\Dir1\\Dir2"; print "Path before change :$path:\n"; $path =~ s/\\/\//g; print "Path after change :$path:\n"; ##################################### my $fs_path = File::Spec->catdir('C:','Dir1','Dir2'); print "Path before change :$fs_path:\n"; $fs_path=File::Spec::Unix->catdir($fs_path); print "Path after change :$fs_path:\n";

      It's not a builtin-part-of-the-language, but File::Spec is builtin-part-of-the-core-distribution (see perlmodlib for the complete list).

      While reading the title of OP, I was also thinking of using File::Spec module. In my version, however, usage of that module would have been limited only to get the path separator for the host OS|file system, and '/' would have been used literally per request.
Re: changing the path name to unix style.
by rinceWind (Monsignor) on Dec 13, 2006 at 12:04 UTC

    If you want something that doesn't hurt the eyes, try this for size:

    $path =~ s(\\)(/);

    What you have is referred to as the Leaning Toothpick Syndrome.

    --

    Oh Lord, won’t you burn me a Knoppix CD ?
    My friends all rate Windows, I must disagree.
    Your powers of persuasion will set them all free,
    So oh Lord, won’t you burn me a Knoppix CD ?
    (Missquoting Janis Joplin)

Re: changing the path name to unix style.
by vladdrak (Monk) on Dec 13, 2006 at 07:48 UTC
    Also, you can usually reference Windows paths with a forward slash. Unless you're executing a shell command with ``, system() or open() and the path is being passed to an exe that doesn't understand the format. Perl gets it though.