Absolute paths with multiple volumes

Discussion in 'Perl' started by Donald, Mar 7, 2004.

  1. Donald

    Donald Guest

    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>myscript fred
    -----> c:\myarea\fred

    c:\myarea>myscript d:fred
    -----> d:\current_directroy_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.
     
    Donald, Mar 7, 2004
    #1
    1. Advertising

  2. In article <404b0112$>, Donald wrote:
    > 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>myscript fred
    > -----> c:\myarea\fred
    >
    > c:\myarea>myscript d:fred
    > -----> d:\current_directroy_of_volume_D\fred
    >


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

    Cheers, Roel van der Steen
     
    Roel van der Steen, Mar 7, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Noah
    Replies:
    5
    Views:
    790
  2. DD
    Replies:
    3
    Views:
    4,130
    Jeff Higgins
    Nov 28, 2007
  3. user923005

    Re: C/C++ User's Group Disk Volumes?

    user923005, Jul 11, 2008, in forum: C Programming
    Replies:
    4
    Views:
    530
    user923005
    Jul 12, 2008
  4. Replies:
    1
    Views:
    562
  5. dmoore
    Replies:
    5
    Views:
    239
    spillz
    May 6, 2009
Loading...

Share This Page