in reply to Platform independant directory separator

Use the canonpath function in the File::Spec::Functions module. It's part of the Perl's core distribution.

use File::Spec::Functions qw/ canonpath /; # it's a good idea to use relative path for portability my $platform_independent_path = canonpath "../data/somepath/somedata.txt"; my $directory_separator = canonpath "/";

Replies are listed 'Best First'.
Re^2: Platform independant directory separator
by adrianh (Chancellor) on Mar 01, 2004 at 23:06 UTC
    my $platform_independent_path =       canonpath "../data/somepath/somedata.txt"; my $directory_separator =       canonpath "/";

    Erm. No.

    All canonpath does is clear up a directory in to a canonical for for a specific platform - it's not platform independent in any way.

    For example running your code on a Mac OS 9 box would set $directory_separator to "/" when it would more accurately be ":".

    As rinceWind points out the idea of a single separator isn't valid on some platforms in any case.