Command line args..? 
Author Message
 Command line args..?

Does anyone know a way to use  "-?" as a command line arg?
I set -s in my perl script but I can't seem to get $? or ARGV[0] to
cough up anything for me. Anything else, like a -c or whatnot works fine and
turns up $c = 1 etc..

                                                Thanks for your help



Sat, 04 Dec 1999 03:00:00 GMT  
 Command line args..?


Quote:
> Does anyone know a way to use  "-?" as a command line arg?
> I set -s in my perl script but I can't seem to get $? or ARGV[0] to
> cough up anything for me. Anything else, like a -c or whatnot works fine and
> turns up $c = 1 etc..

At a guess, you're running on a Unix system, using a shell like sh or
csh.  In those shells, the '?' character is a wildcard matching a
single character.  So... your commandline contains an argument that
will be substituted with a one-character-long filename, if one exists
in the current directory.  

You'll need to enclose that argument in single quote to protect it
from the shell.

-Dean
--

Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-3936)
PGP ID=768/22A1A015 Keyprint=2D 53 87 53 72 4A F2 83  A0 BF CB C0 D1 0E 76 C0



Sat, 04 Dec 1999 03:00:00 GMT  
 Command line args..?


: Does anyone know a way to use  "-?" as a command line arg?

It seems that the answer is no, because (by default) the Getopt
modules use $opt_whatever as the variable representing a value for the
switch.  Last time I checked, one couldn't declare a variable $opt_?.

--
Nathan V. Patwardhan



Sun, 05 Dec 1999 03:00:00 GMT  
 Command line args..?



Quote:

>: Does anyone know a way to use  "-?" as a command line arg?

>It seems that the answer is no, because (by default) the Getopt
>modules use $opt_whatever as the variable representing a value for the
>switch.  Last time I checked, one couldn't declare a variable $opt_?.

Yes, but you can use the other forms e.g.

$ cat try.pl
#!/usr/local/bin/perl -w

use Getopt::Std;

getopt '?x', \%opts;
foreach $option (keys %opts) {
  print "saw $option\n";

Quote:
}

__END__
$ ./try.pl '-?'
saw ?

Hope this helps,

Mike

--

http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41



Sun, 05 Dec 1999 03:00:00 GMT  
 Command line args..?

: getopt '?x', \%opts;

Neat!

--
Nathan V. Patwardhan



Sun, 05 Dec 1999 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Hiding command-line args?

2. command-line args style flags from a file

3. Debug .pl Syntax of command line args ?

4. Case-insensitive Command Line Args

5. command line args not working correctly

6. HELP: How to program command line args

7. perl command line args

8. perl command line args

9. Command line args

10. Question: Perl for Windows command line args?

11. Getting command line args

12. command line args to "perl"

 

 
Powered by phpBB® Forum Software