On 7/6/07, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
I wrote a simple perl script and execute it as follows: "./sr /tmp/*"

#!/usr/bin/perl
print $ARGV[0];

Well, what is returned is the first filename in the directory, instead
of the actual argument itself. What can I do to get the literal
argument?

Quote it on the command line. Check your shell's documentation to
learn its particular quoting rules and metacharacters. Or you can
probably get by with single quotes:

 $ ./sr '/tmp/*'

Alas, on Unix systems, there is no way in general to retrieve the
literal argument string; all that's available to your program is what
the shell supplies, which is in @ARGV. So users of your program have
to quote shell metacharacters in command-line arguments to your
program. If it's any consolation, they have to do that with every
other program they run as well.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to