best way to build an absolute spec

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

  1. oldyork90

    oldyork90 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.
     
    oldyork90, Jun 1, 2014
    #1
    1. Advertisements

  2. oldyork90

    oldyork90 Guest

    oldyork90, Jun 1, 2014
    #2
    1. Advertisements

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.