Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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 surveying the Monastery: (2)
As of 2025-12-15 18:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (95 votes). Check out past polls.

    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.