Without code I can only guess what you are doing with @ARGV. I suspect you're using Getopt::Long, which is fine. If there's some other method of processing @ARGV that you're using we should probably know, because that may be relevant.

That said, why don't you try perl test.pl --file="test.txt", and perl test.pl --file="C:\scripts\test.txt"? The shell will remove the double-quotes anyway, so unless there are special characters you want to preserve, the quoting isn't doing anything for you to begin with.

Note the following:

perl -e "print qq{<<$_>>\n} for @ARGV" file=test\test\test __OUTPUT__ <<file=test\test\test>>

In other words, even without quotes, the backslashes are preserved.

Now try the same one-liner with double-quotes around the path. The output will demonstrate that the shell is stripping them away. Single quotes don't have that syntactic meaning under Windows.


Dave


In reply to Re: How to pass Windows filepaths on command line by davido
in thread How to pass Windows filepaths on command line by bangor

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.