Thread [Getopt::Long] getOptions - Fehlerermittlung bei gleicher Option (14 answers)
Opened by bora99 at 2015-09-10 11:41

bora99
 2015-09-10 16:24
#182138 #182138
User since
2009-12-05
54 Artikel
BenutzerIn
[default_avatar]
sorry, habe das Array-Handling nicht sauber durchgeführt , auch die Initalisierung, so jetzt sollte es passen

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/perl -w

use strict;
use Getopt::Long;

my %Args = ();
my @option = ();
my $option = "";

my $help = 0;

print "ARGV: @ARGV\n";

my $InOpts = GetOptions( \%Args,
'o|option=s' => \@option,
'h|help' => \$help ) or die "usage option ...";

print "Usage ..." if( ! $InOpts);
print "help ..." if( $help );

my $array_anz = @option;

print "ArrayInfo: Optionen: @option ArrayAnz: $array_anz \$#: $#option\n";

print "too much -o @option !!\n" if (@option>1);


habe mir gerade ausgeborgt ein Uralt Perl Buch , wo drinnen steht

Code: (dl )
1
2
if ( ($#ARGV + 1) < 1 ) { die "$0 erfordert ein Argument.\n"; }
mit Erklärung: keine Argument ...


sollte ja heissen
Code: (dl )
if ( @ARGV == 0 ) { die "$0 erfordert ein Argument.\n"; }

oder ?

View full thread [Getopt::Long] getOptions - Fehlerermittlung bei gleicher Option