in reply to Re: (tye)Re: ADD PATH TO @INC
in thread ADD PATH TO @INC

or, iirc, you can just use forward slashes ala

print "C:/ads/lib";

and perl will automagically convert it on win32.

anders pearson // digital samurai
personal      // http://www.columbia.edu/~anders/
weblog       // http://thraxil.dhs.org/

Replies are listed 'Best First'.
(tye)Re2: ADD PATH TO @INC
by tye (Sage) on Jun 19, 2001 at 10:39 UTC

    Perl doesn't do much automatic convert of / to \ on Win32. I think it is actually more common that some modules convert \ to / when on Win32 so that the rest of their code doesn't have to deal with \ directory separators.

    The fact is that Win32 allows / as a directory separator in almost all places. The few exceptions I have found include

    • Many programs that use / for command-line options (such as most programs from Microsoft) won't let you use / as a directory separator for file names on their command line.
    • The standard "open file dialog" controls don't allow / as a directory separator.
    • The DefineDosDevice() API call doesn't allow the use of / in the definition of a "raw target path".
    So, in Perl on Win32, you will only very rarely run into problem using / as a directory separator except if you try to use it on some other program's command line.

    Unfortunately, there are also some fairly rare cases where using \ as a directory separator will cause you problems in Perl, so there isn't just one simple solution.

            - tye (but my friends call me "Tye")
Re: Re: Re: (tye)Re: ADD PATH TO @INC
by myocom (Deacon) on Jun 19, 2001 at 03:20 UTC

    Yes and no. Your code, print "C:/ads/lib"; will print C:/ads/lib. But Perl on Win32 will correctly understand / as a path separator (e.g., open FILE, 'C:/ads/lib/file.txt';).