#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use Getopt::Long;
my $result = GetOptions (
h => \&help,
d => sub {print "\nRun DEV COMPARE\n";},
p => \&PROD,
);
say "result: $result";
bad_option() unless $result;
say "\ncontinuing normally";
say "Doing stuff.....";
say "exiting normally";
sub PROD {print "\nRun Production COMPARE\n";}
sub help {print "\nHelp text\n";}
sub bad_option {
print "\nInvalid option detected... Quitting!!!\n";
exit 1;
}
####
./pm-888730 -h -d -p
Help text
Run DEV COMPARE
Run Production COMPARE
result: 1
continuing normally
Doing stuff.....
exiting normally
####
./pm-888730 -d -x
Run DEV COMPARE
Unknown option: x
result:
Invalid option detected... Quitting!!!