Hello,

I'm trying to use Getopt::Long for parsing parameters passed to a
function. I tried to test if that works by using the following script.

-------------------------------------------------------
#!/usr/bin/perl -w
use strict;
use Getopt::Long;

sub test_params()
{
   @ARGV=@_;
   print "ARGV: @ARGV\n";

   my $a=0;
   my $b=0;
   my $c=0;

   GetOptions( "a|opta=s"   => \$a,
               "b"          => \$b,
               "c|optc"     => \$c );

   print "opta: $a\n";
   print "optb: $b\n";
   print "optc: $c\n\n\n";
}

&test_params("-a argument_a -b -c");
&test_params("--opta argument_a -b -c");
&test_params("-b");
&test_params("-c -b");
-------------------------------------------------------

Unfortunately it doesn't work. The first call to the function gives the
following output:

      ARGV: -a argument_a -b -c
      Unknown option: a argument_a -b -c
      opta: 0
      optb: 0
      optc: 0

As you can see the module complains about an unkown option. The dash before the
'a' is missing, so I suppose that it has something to do with the error. If the
functions is called with only one parameter then it works.

Any hints on how to get it working?

Cheers
Robert

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to