Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Backslashes in command arguements

by kyle (Abbot)
on Feb 26, 2007 at 17:06 UTC ( [id://602169]=note: print w/replies, xml ) Need Help??


in reply to Backslashes in command arguements

It would probably be useful to print out $hostName before you use it. Your double backslash on the command line ("foo.pl \\hostname") may be converted to a single backslash when Perl gets it, but I'm guessing that it's getting converted in the backticks. You can escape them before it gets there like so:

$hostName =~ s/\\/\\\\/g;

Update: Thanks to ikegami for pointing out that my speculation was off the mark. DOS does not mangle backslashes on the command line. I thought it might, so I suggested printing out the variable to be sure. I'd have checked this myself, but I don't have Perl on Windows to try.

Replies are listed 'Best First'.
Re^2: Backslashes in command arguements
by ikegami (Patriarch) on Feb 26, 2007 at 17:24 UTC

    Your double backslash on the command line ("foo.pl \\hostname") may be converted to a single backslash when Perl gets it

    No.

    >perl -e "print $ARGV[0]" \\hostname \\hostname

    If there's a slash missing, it was removed *before* Perl got it.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2025-03-24 20:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (65 votes). Check out past polls.

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.