best way to build an absolute spec

Discussion in 'Perl Misc' started by oldyork90@yahoo.com, Jun 1, 2014.

  1. Guest

    I have a directory $my_dir. I test this with -d.
    $my_dir is user defined.

    I want to build the file spec "$my_dir . $my_fn", but $my_dir may be
    constructed as either /one/two or /one/two/.

    I could test for the trailing path separator and act accordingly, but is
    there a better way, a "standard" or best practice way, of doing this?

    How do you pros build the absolute paths?


    I find that in Windows "/one/two//my_file" will work, but I'd rather not.

    Thanks in advance.
    , Jun 1, 2014
    #1
    1. Advertising

  2. Guest

    , Jun 1, 2014
    #2
    1. Advertising

  3. writes:
    > I have a directory $my_dir. I test this with -d.
    > $my_dir is user defined.
    >
    > I want to build the file spec "$my_dir . $my_fn", but $my_dir may be
    > constructed as either /one/two or /one/two/.
    >
    > I could test for the trailing path separator and act accordingly, but is
    > there a better way, a "standard" or best practice way, of doing this?
    >
    > How do you pros build the absolute paths?
    >
    >
    > I find that in Windows "/one/two//my_file" will work, but I'd rather
    > not.


    POSIX/ UNIX(*) pathnames may separate two components with any number of
    /-characters (subject to pathname lenght limits).
    Rainer Weikusat, Jun 1, 2014
    #3
    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. Victor Porton
    Replies:
    0
    Views:
    396
    Victor Porton
    Jun 1, 2004
  2. Andrew Chen
    Replies:
    1
    Views:
    189
    David Chelimsky
    Mar 25, 2008
  3. James Byrne
    Replies:
    3
    Views:
    549
    James Byrne
    Sep 14, 2010
  4. Peter Havens
    Replies:
    0
    Views:
    105
    Peter Havens
    Mar 17, 2011
  5. Henry Law
    Replies:
    4
    Views:
    118
    Anno Siegel
    Sep 15, 2005
Loading...

Share This Page