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. Advertisements

  2. Guest

    , Jun 1, 2014
    #2
    1. Advertisements

  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. Advertisements

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:
    500
    Victor Porton
    Jun 1, 2004
  2. Alan Silver
    Replies:
    0
    Views:
    711
    Alan Silver
    May 30, 2006
  3. Replies:
    2
    Views:
    472
  4. Codex Twin

    Best way to build a form dynamically

    Codex Twin, Feb 14, 2005, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    212
    Codex Twin
    Feb 14, 2005
  5. Andrew Chen
    Replies:
    1
    Views:
    365
    David Chelimsky
    Mar 25, 2008
  6. James Byrne
    Replies:
    3
    Views:
    890
    James Byrne
    Sep 14, 2010
  7. Peter Havens
    Replies:
    0
    Views:
    211
    Peter Havens
    Mar 17, 2011
  8. Bart van den Burg

    Best way to build up XHTML

    Bart van den Burg, Jan 11, 2005, in forum: Perl Misc
    Replies:
    5
    Views:
    144
    Vetle Roeim
    Jan 13, 2005
Loading...