in reply to absolute pathname

File::Spec->rel2abs($0)

Replies are listed 'Best First'.
Re^2: absolute pathname
by maletin (Sexton) on Aug 12, 2008 at 21:27 UTC
    rel2abs() has problems with volumes:
    If $base is not present or ’’, then Cwd::cwd() is used. If $base is relative, then it is converted to absolute form using "rel2abs()". This means that it is taken to be relative to Cwd::cwd(). On systems with the concept of volume, if $path and $base appear to be on two different volumes, we will not attempt to resolve the two paths, and we will instead simply return $path.

      That doesn't seem to apply to Windows.

      D:\>perl c:script.pl C:\path\script.pl D:\>perl c:..\ikegami\script.pl C:\path\script.pl

      I could still apply to other systems, though (VMS?)

      Update: Looking at the source, it uses getdcwd (as opposed to getcwd) with the appropriate volume, returning the correct path even when different volumes are involved.