Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: changing the path name to unix style.

by nimdokk (Vicar)
on Dec 13, 2006 at 12:57 UTC ( #589574=note: print w/ replies, xml ) Need Help??


in reply to changing the path name to unix style.

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


Comment on Re: changing the path name to unix style.
Download Code
Re^2: changing the path name to unix style.
by Fletch (Chancellor) on Dec 13, 2006 at 14:45 UTC

    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).

Re^2: changing the path name to unix style.
by parv (Priest) on Dec 14, 2006 at 00:30 UTC
    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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://589574]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (11)
As of 2014-07-30 09:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (230 votes), past polls