Absolute paths with multiple volumes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Donald

    Absolute paths with multiple volumes

    I am writing a simple perl program that is normally called from the command
    line with a filename as an argument. I need the full absolute path and name
    for this file. It is for WIN32 system that has multiple volumes (ie C: D:)

    Examples
    c:\myarea>myscr ipt fred
    -----> c:\myarea\fred

    c:\myarea>myscr ipt d:fred
    -----> d:\current_dire ctroy_of_volume _D\fred

    I am new to perl but have searched extensively for a SIMPLE solution. It
    seems to be a straightforward enough task and I am wondering whether I am
    missing something obvious.

    The file in question will always exist and has a file handle if that helps.

    Regards


    Donald.


  • Roel van der Steen

    #2
    Re: Absolute paths with multiple volumes

    In article <404b0112$1@dus ter.adelaide.on .net>, Donald wrote:[color=blue]
    > I am writing a simple perl program that is normally called from the command
    > line with a filename as an argument. I need the full absolute path and name
    > for this file. It is for WIN32 system that has multiple volumes (ie C: D:)
    >
    > Examples
    > c:\myarea>myscr ipt fred
    > -----> c:\myarea\fred
    >
    > c:\myarea>myscr ipt d:fred
    > -----> d:\current_dire ctroy_of_volume _D\fred
    >[/color]

    #!perl
    use Cwd 'abs_path';
    use File::Spec;
    ($vol, $dir, $file) = File::Spec->splitpath('d:f red');
    print File::Spec->catfile( abs_path("$vol$ dir"), $file );

    Cheers, Roel van der Steen

    Comment

    Working...