FAQ 5.36 Why can't I use "C:\temp\foo" in DOS paths? Why doesn't `C:\temp\foo.exe` work?

Discussion in 'Perl Misc' started by PerlFAQ Server, Apr 26, 2011.

  1. This is an excerpt from the latest version perlfaq5.pod, which
    comes with the standard Perl distribution. These postings aim to
    reduce the number of repeated questions as well as allow the community
    to review and update the answers. The latest version of the complete
    perlfaq is at http://faq.perl.org .

    --------------------------------------------------------------------

    5.36: Why can't I use "C:\temp\foo" in DOS paths? Why doesn't `C:\temp\foo.exe` work?

    Whoops! You just put a tab and a formfeed into that filename! Remember
    that within double quoted strings ("like\this"), the backslash is an
    escape character. The full list of these is in "Quote and Quote-like
    Operators" in perlop. Unsurprisingly, you don't have a file called
    "c:(tab)emp(formfeed)oo" or "c:(tab)emp(formfeed)oo.exe" on your legacy
    DOS filesystem.

    Either single-quote your strings, or (preferably) use forward slashes.
    Since all DOS and Windows versions since something like MS-DOS 2.0 or so
    have treated "/" and "\" the same in a path, you might as well use the
    one that doesn't clash with Perl--or the POSIX shell, ANSI C and C++,
    awk, Tcl, Java, or Python, just to mention a few. POSIX paths are more
    portable, too.



    --------------------------------------------------------------------

    The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
    are not necessarily experts in every domain where Perl might show up,
    so please include as much information as possible and relevant in any
    corrections. The perlfaq-workers also don't have access to every
    operating system or platform, so please include relevant details for
    corrections to examples that do not work on particular platforms.
    Working code is greatly appreciated.

    If you'd like to help maintain the perlfaq, see the details in
    perlfaq.pod.
     
    PerlFAQ Server, Apr 26, 2011
    #1
    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. Replies:
    3
    Views:
    399
    John Roth
    Jul 29, 2005
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,137
    Smokey Grindel
    Dec 2, 2006
  3. .rhavin grobert

    vector: Foo[5] == ((foo*)Foo) + 5 ?

    .rhavin grobert, Sep 23, 2008, in forum: C++
    Replies:
    4
    Views:
    414
    JaredGrubb
    Sep 24, 2008
  4. Sol Linderstein
    Replies:
    3
    Views:
    208
    Matt Garrish
    Jun 18, 2004
  5. Replies:
    4
    Views:
    165
    Thomas 'PointedEars' Lahn
    Dec 23, 2007
Loading...

Share This Page