#!/usr/bin/env perl use warnings; use strict; use Getopt::Long; GetOptions( 'first' => \&first, 'second' => \&second, 'help' => \&help, ) or die "Invalid options passed to $0\n"; sub first () { print "Processing sub first\n"; } sub second () { print "Processing sub second\n"; } sub help () { print "Available options are: \n"; print "\t--first\n"; print "\t--second\n"; print "\t--third\n"; print "\t--fourth\n"; print "\t--help\n"; } #### ***** Output ******* C:\temp>getopts.pl --year --first Unknown option: year Processing sub first Invalid options passed to C:\temp\getopts.pl