オプション
#!/usr/bin/perl use strict; use warnings; use Getopt::Std; $Getopt::Std::STANDARD_HELP_VERSION = 1; # standard-conforming behaviour our( $opt_v, $opt_h, $opt_a, ); getopts('vha:'); print "v: $opt_v\n" if ($opt_v); print "h: $opt_h\n" if ($opt_h); print "a: $opt_a\n" if ($opt_a);
$ opt.pl -v v: 1 $ opt.pl -vh v: 1 h: 1 $ opt.pl -v -a 10 v: 1 a: 10 $ opt.pl -h -a h: 1