Re: [ILUG] Path separator in Perl

From: Dave O Connor (doc at domain redbrick.dcu.ie)
Date: Fri 12 May 2000 - 12:19:53 IST


Someone called Peter McEvoy said on Fri, May 12, 2000 at 12:07:29PM +0100:
> Anyone know of a platform independant way of figuring out what the path
> separator is in Perl (/ vs \)? (I'm developing on NT for use on a UNIX
> machine, and I'm doing a lot of stuuf with path manipulation/searching).
>
The Special variable $^O is always equal to the OS type the script is running
on. So something like:

if($^O eq "WIN32")
{
        $seperator = "\";
}
else
{
        $seperator = "/";
}

It mightn't be "WIN32", I don't have a windows box to find that out, more's
the pity. Try printing it out first to find out, then use the if.

        - DoC



This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:06:07 GMT