Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: How to write a perl script to work on many OS(s)

by swampyankee (Parson)
on Jul 06, 2007 at 04:58 UTC ( [id://625192]=note: print w/replies, xml ) Need Help??


in reply to How to write a perl script to work on many OS(s)

Use forward slashes (aka virgules). Generally, Perl will treat / as the path delimiter in Windows; see here. Quoting: "Since all DOS and Windows versions since something like MS-DOS 2.0 or so have treated / and \ the same in a path, you might as well use the one that doesn't clash with Perl--or the POSIX shell, ANSI C and C++, awk, Tcl, Java, or Python, just to mention a few. POSIX paths are more portable, too." (perlfaq5)

Note that different shells have different quoting conventions, and different methods of determining when variable substitution should take place.

emc

Any New York City or Connecticut area jobs? I'm currently unemployed.

There are some enterprises in which a careful disorderliness is the true method.

—Herman Melville
  • Comment on Re: How to write a perl script to work on many OS(s)

Replies are listed 'Best First'.
Re^2: How to write a perl script to work on many OS(s)
by archfool (Monk) on Jul 06, 2007 at 15:06 UTC
    Forward slashes generally work in Perl MSWin32. There are a few corner cases where this doesn't work. ALSO... don't forget that windows shares need to start with two slashes... I believe File::Spec::canonpath will collapse them down to one, causing problems.

      Thanks; I wasn't aware of File::Spec::canonpath collapsing leading double slashes to one. I'll watch out for that in the future.

      emc

      Any New York City or Connecticut area jobs? I'm currently unemployed.

      There are some enterprises in which a careful disorderliness is the true method.

      —Herman Melville
Re^2: How to write a perl script to work on many OS(s)
by GrandFather (Saint) on Jul 06, 2007 at 05:42 UTC

    Fine for *nix and DOS/Windows, but not so good for Mac and others maybe?


    DWIM is Perl's answer to Gödel
      For Mac OS 9 and older you should use ":" as a path separator, but Mac OS X uses "/" just fine.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-25 11:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found