Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Command line argument Error..

by khjayantasingh (Initiate)
on Jan 31, 2013 at 10:59 UTC ( #1016288=perlquestion: print w/ replies, xml ) Need Help??
khjayantasingh has asked for the wisdom of the Perl Monks concerning the following question:

I want to Give a command line argument in a Perl script.
display.pl.... #!/usr/bin/perl print "@ARGV\n";
################ I give a command line argument
perl display.pl net/*/*
But It gives an error...
perl: No match.
If i give argument like
perl display.pl 'net/*/*' or perl display.pl "net/*/*"
It is working find... but problem is I cannot use like this in my script.. So please tell me why this script is giving an error... and any means to make it work..

Comment on Command line argument Error..
Select or Download Code
Re: Command line argument Error.. (shell)
by Anonymous Monk on Jan 31, 2013 at 11:10 UTC

    perl isn't giving that error, your shell is

    Try  ls net/*/* and you'll likely get the same message

Re: Command line argument Error..
by roboticus (Canon) on Jan 31, 2013 at 11:14 UTC

    khjayantasingh:

    It sounds like your command shell is mangling the arguments for you (most do in one way or another).

    Most shells will try to expand the argument list for you when they see a wildcard. Putting quotes around the arguments tells the shell to pass the argument to the script as written. Example:

    $ perl t.pl t* t.100, t.100.md5, t.10.md5, t.pl $ perl t.pl 't*' t* $ cat t.pl use strict; use warnings; print join(", ", @ARGV),"\n";

    In the first run, perl didn't get t*, the shell expanded t* to a list of all matching files and gave that list to the perl script. For the second run, I quoted the argument, so perl actually sees t*.

    I'd go further, but your question is somewhat difficult for me to interpret: "but problem is I cannot use like this in my script". I can't tell what's giving you a problem from this point. Care to elaborate?

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

Re: Command line argument Error..
by vinoth.ree (Parson) on Jan 31, 2013 at 11:17 UTC

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2014-09-20 12:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (159 votes), past polls