Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Argv problem

by Anonymous Monk
on Mar 04, 2013 at 08:49 UTC ( #1021605=perlquestion: print w/replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:


I am using @ARGV to take input but whenever i enter & as value in any field than I get an error. The @ARGV takes four arguments so when any field is given & as input than a error messagethat is insufficient arguments is generated which I have written myself. Please explain why is this happening?

Replies are listed 'Best First'.
Re: Argv problem
by choroba (Chancellor) on Mar 04, 2013 at 08:53 UTC
    Did you quote the &? If not, it is possible that your shell interpreted it and did not pass it as an argument to your script.

    This works for me in bash:

    perl -e 'print for @ARGV' 1 \& 2
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: Argv problem
by QM (Parson) on Mar 04, 2013 at 08:53 UTC
    In most shells & is interpreted as "put this process in the background". So the shell is likely eating that, and leaving your script without. Try single or double quoting (depends on shell).

    BTW, & is probably a poor choice for an argument. Can you change it to something else?

    Quantum Mechanics: The dreams stuff is made of

      Its a password field so it can have any value , so user can enter & also.

        It's probably a bad idea to let the user enter a visible password. That said, suggest that the user quote the password or escape special characters, noting that in some shells, some characters are ridiculously difficult to quote correctly.

        Also search here and elsewhere. A quick search turned up Inputting a password w/o having it displayed on screen, which may help.

        Quantum Mechanics: The dreams stuff is made of

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1021605]
Approved by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2016-10-22 16:23 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (297 votes). Check out past polls.