Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: How to pass Windows filepaths on command line

by davido (Cardinal)
on Aug 28, 2014 at 17:55 UTC ( [id://1098896]=note: print w/replies, xml ) Need Help??


in reply to How to pass Windows filepaths on command line

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1098896]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2026-04-20 07:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.