Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Paths in Perl

by John M. Dlugosz (Monsignor)
on Sep 05, 2001 at 02:35 UTC ( #110185=note: print w/replies, xml ) Need Help??


in reply to Paths in Perl

The Opposing View

Using '/' for paths in Perl gives almost no problems on DOS and Windows machines, because the underlying OS accepts / as a synonym for \ (most of the time).

But is that true for all OS's and platforms? Like someone already said, it doesn't work on the Mac. The Perl interpreter itself might change / to : before calling the OS, but what about real /'s in file names, like "notes from 4/27/99"? What about :'s in the file name?

A solid program should always use the native path separator and do so uniformly and consistantly.

If that's not handy, Perl 6 will reportetly offer uniform URL support, so you can use file:// notation on files on any OS, with %xx for funny chars and / for seperators. There might also be a module that deals with paths as a collection of nodes and abstracts the actual syntax.

And just because the OS takes / as an alias, or Perl translates for you behind the scenes, what happens to individual programs you invoke? In the COMMAND.COM shell, the / will parse wrong, as we saw on a recient posting. A program might get confused if / and \ are mixed in the same string. Who knows? you're at the mercy of whoever wrote that program!

—John

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://110185]
help
Chatterbox?
[Discipulus]: fall asleep? coffee time!
Discipulus when in motorbike it is impossible to fall asleep.. another advantage
marioroy I once fell asleep while drive and had no collection on how I exited the ramp. Then called my wife not knowing where I was totally lost.
marioroy At a large firm, had to awaken a security guy a few times so that nobody would catch him sleeping.

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2017-05-29 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?