use warnings; use strict; use Getopt::Long; my $do_first = 0; sub first { $do_first = 1 } my $do_second = 0; sub second { $do_second = 1 } GetOptions(first=>\&first, second=>\&second) or die "Invalid options passed to $0\n"; if ($do_first) { print "First!\n" } if ($do_second) { print "Second!\n" } __END__ $ perl 11140961.pl --first --second --first --second --second --first First! Second! $ perl 11140961.pl --first --second --year --first --second --second --first Unknown option: year Invalid options passed to 11140961.pl