Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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: "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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2015-05-04 03:08 GMT
Find Nodes?
    Voting Booth?

    In my home, the TV remote control is ...

    Results (79 votes), past polls