Newbie ?: @ARGV not getting command line arguments 
Author Message
 Newbie ?: @ARGV not getting command line arguments

I'm running ActivePerl build 507 in a WindowsNT environment and when I
call GetOpts.pl, my command line arguments are not passed.  Instead it's

passing "%*"

Any ideas?




Wed, 18 Jun 1902 08:00:00 GMT  
 Newbie ?: @ARGV not getting command line arguments

Quote:

> I'm running ActivePerl build 507 in a WindowsNT environment and when I
> call GetOpts.pl, my command line arguments are not passed.  Instead it's

> passing "%*"

> Any ideas?

Post enough of the code to illustrate the problem.  And cut-and-paste
working code - don't try to retype it.

Since you haven't munged your address, OK.

- Tom



Wed, 18 Jun 1902 08:00:00 GMT  
 Newbie ?: @ARGV not getting command line arguments
At the command line, I type test2.pl -a <argument> -bc <argument>
******************************************************************
#! /opt/local/bin/perl
#
#require "getopts.pl";
#
&Getopts("a:bc");
#
printf ("a ($opt_a)\n");
printf ("b ($opt_b)\n");
printf ("c ($opt_c)\n");
#
#
;# getopts.pl - a better getopt.pl

;# Usage:
;#      do Getopts('a:bc');  # -a takes arg. -b & -c not. Sets opt_* as
a
;#                           #  side effect.

sub Getopts {


    local($errs) = 0;




printf("Next line in code is while loop\n");



printf("If this prints, the while loop works\n");

 printf("$1,$2,$3,$4,$5,$6,$7,$8,$9\n");
        ($first,$rest) = ($1,$2);
 printf("argumentative = $argumentative\n");
 printf("first = $first\n");
 printf("rest = $rest\n");

        $pos = index($argumentative,$first);

 printf("pos = $pos\n");

        if($pos >= 0) {
     printf("args = $#args\n");
     printf("args(0) = $args[$pos+1]\n");
            if($pos < $#args && $args[$pos+1] eq ':') {

                if($rest eq '') {


                }
                ${"opt_$first"} = $rest;
  printf("optfirst = opt_$first\n");
  printf ("rest = $rest\n");
            }
            else {
                ${"opt_$first"} = 1;
                if($rest eq '') {

                }
                else {
                    $ARGV[0] = "-$rest";
                }
            }
        }
        else {
            print STDERR "Unknown option: $first\n";
            ++$errs;
            if($rest ne '') {
                $ARGV[0] = "-$rest";
            }
            else {

            }
        }
    }
    $errs == 0;

Quote:
}

1;
**********************************************************************


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Q: @ARGV not getting command line arguments

2. Getting command line arguments from cgi script (@ARGV)

3. command line argument (newbie)

4. ARGV validation of command line options

5. ANNOUNCE Beta Argv package (was: command line parsing)

6. command line params @ARGV

7. -F works on command line but not on #!perl -paF line

8. Help! with command line arguments

9. running perl at command line with arguments: script.cgi?text=text

10. Command line arguments.

11. Simple reordering of command line arguments.

12. Command line arguments?

 

 
Powered by phpBB® Forum Software