#!/usr/local/bin/perl -w
use Getopt::Long;
my ($hello,$goodbye); # option switches
GetOptions (
"hello" => \$hello,
"goodbye" => \$goodbye,
);
if ($hello) {
print "Hello world\n";
}
if ($goodbye) {
print "Goodbye!\n";
}
####
# use full options
> perl test.pl --hello --goodbye
Hello world
Goodbye!
####
# use abbreviation
> perl test.pl -h
Hello world