Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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.

Replies are listed 'Best First'.
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: "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: "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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://842768]
Approved by wfsp
Front-paged by MidLifeXis
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2017-06-23 07:15 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (536 votes). Check out past polls.