At 14:59 +0900 2001.07.12, Nobumi Iyanaga wrote:
>I am writing some scripts for cross-platform use.  How can I determine the
>OS on which a script is running?  If it is a Mac, I will use ":" as
>directory separator; if it is a Windows, I will use "\\", and if it is a
>Unix, I will use "/".

To add to what Thomas and Scott said:

It is best to not try to guess.  Use the File::Spec and File::Basename
modules whenever possible.  MacPerl 5.2.0r4 does not include File::Spec,
but every later version of perl (5.005 and up) does, and you can download
it from CPAN.

The problem with trying to guess path separators is that it won't always
work.  It is best to use the modules, which take care of all the details.

Although, as noted, $^O is the variable containing the OS name.

See http://pudge.net/macperl/macperlmodinstall.html for information on
installing modules under MacPerl.  See
http://pudge.net/macperl/perlport.html for more information on $^O.

If you have trouble using the modules, please just ask for help on the
list, we'll do what we can.

-- 
Chris Nandor                      [EMAIL PROTECTED]    http://pudge.net/
Open Source Development Network    [EMAIL PROTECTED]     http://osdn.com/

Reply via email to