programming-examples/perl/SystemFunction/Using Getopt to deal with command line options.pl
2019-11-15 12:59:38 +01:00

25 lines
492 B
Perl

#!/usr/bin/perl -w
use Getopt::Std;
Getopt::Std::getopts( 'a:b:c:de' );
# Options appear in variables named opt_option, e.g., opt_a.
if ( defined( $opt_a ) ) {
print "-a flag set to $opt_a\n";
}
if ( defined( $opt_b ) ) {
print "-b flag set to $opt_b\n";
}
if ( defined( $opt_c ) ) {
print "-c flag set to $opt_c\n";
}
if ( defined( $opt_d ) ) {
print "-d flag set to $opt_d\n";
}
if ( defined( $opt_e ) ) {
print "-e flag set to $opt_e\n";
}