Comment detail

起動オプションの解析 (Nested Flatten)
-d は、必須オプションとして処理しています。
 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
use strict;
use Getopt::Std;

#ex>cmdopt -o [-q] -d{0|1|2} 文字列 [文字列 ...]

our( $opt_o, $opt_q, $opt_d );

getopts('oqd:');

die "oオプションが指定されていない\n" unless $opt_o;
die "dオプションが指定されていない\n" unless defined $opt_d;
die "dオプションの引数は0-2\n" unless ($opt_d eq '0' || $opt_d eq '1' || $opt_d eq '2');
die "パラメータが指定されていない\n" unless @ARGV;

print "[オプション情報]\n";
print "o(output): ON\n" if $opt_o; 
print "q(quote): " . ($opt_q ? "ON" : "OFF") . "\n"; 
print "d(debug): $opt_d\n";

print "\n[パラメータ情報]\n";
printf("指定数: %d\n", $#ARGV+1);

my $c = 0;
for my $arg (@ARGV){
    $c++;
    print "$c: $arg\n";
}

Index

Feed

Other

Link

Pathtraq

loading...