Thread ueberpruefen ob commandline leer ist (19 answers)
Opened by RPerl at 2007-07-28 12:44

Linuxer
 2007-07-28 14:10
#79021 #79021
User since
2006-01-27
3891 Artikel
HausmeisterIn

user image
Hi,

wenn Du @ARGV auf Inhalt prüfen willst, musst Du das vor GetOptions() tun, den GetOptions() modifiziert @ARGV.

Code (perl): (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
26
27
28
29
30
31
32
#!/usr/bin/perl
# vi:ts=4 sw=4 et:
use strict;
use warnings;
use Getopt::Long;

# http://board.perl-community.de/cgi-bin/ikonboard/ikonboard.cgi?act=ST;f=6;t=4491

#> global variables
#> ----------------------------------------------------------------------------

my $change = 0;

#> main script
#> ----------------------------------------------------------------------------

if ( !@ARGV ) {
    die "you didn't mention any options. see help for more.\n";
}
else {
    my $result = GetOptions( "change" => \$change );
    # check $result ...
}

if ( $change ) {
    print "Wanna change...\n";
}
else {
    print "nothing to change...\n";
}

__END__
meine Beiträge: I.d.R. alle Angaben ohne Gewähr und auf Linux abgestimmt!
Die Sprache heisst Perl, nicht PERL. - Bitte Crossposts als solche kenntlich machen!

View full thread ueberpruefen ob commandline leer ist