programming-examples/perl/SystemFunction/Perform consistent command line parsing.pl
2019-11-15 12:59:38 +01:00

18 lines
507 B
Perl

#!/usr/local/bin/perl -w
use 'Getopt::Std'
getopt('abcd:ef:');
print "Switch a is on\n" if $opt_a;
print "Switch b is on \n" if $opt_b;
print "Switch c is on \n" if $opt_c;
print "Debug switch set to $opt_d\n" if $opt_d > 5;
print "Switch e is on\n" if $opt_e;
if ($opt_f) {
print "Cannot locate file $opt_f\n" unless -e $opt_f;
}
for $I (1..5) {
print "Value of I is $I\n" if $opt_d;
}
print "No (more) switches specified\n";