Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Perl Command Line Arguments

by iamravikanth (Novice)
on Jun 02, 2010 at 14:34 UTC ( #842768=perlquestion: print w/ replies, xml ) Need Help??
iamravikanth has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I want to send the following string as a single command line argument in Perl. "A B C D" but whenever i send such a string it treats them as 4 variables, but I need to send it as a single argument. How do I achieve this. Regards, Ravi.

Comment on Perl Command Line Arguments
Re: Perl Command Line Arguments
by moritz (Cardinal) on Jun 02, 2010 at 14:38 UTC
    Either by quoting, or by using the LIST form of system.
      Can you please give an example of quotes?
        $ perl -e 'print ">$_<\n" for @ARGV' A B C D >A< >B< >C< >D< $ perl -e 'print ">$_<\n" for @ARGV' "A B C D" >A B C D<
Re: Perl Command Line Arguments
by dineed (Scribe) on Jun 03, 2010 at 01:32 UTC

    maybe try:

    yourscript.pl "A B C D"
Re: Perl Command Line Arguments
by Hena (Friar) on Jun 03, 2010 at 13:07 UTC
    You have to quote them in execution as dineed mentioned above. The shell you are using is separating the characters (strings) instead of perl interpreter.

    So you need: script.pl "A B C"
Re: Perl Command Line Arguments
by littlemonk (Sexton) on Jun 04, 2010 at 05:39 UTC

    try single quotes instead of double quotes....

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://842768]
Approved by wfsp
Front-paged by MidLifeXis
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (13)
As of 2014-07-29 09:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (213 votes), past polls