use strict; use warnings; use Getopt::Long; my %args; my $result = GetOptions ( "c=s" => \&COMP1, "t=s" => sub { if($args{c}) { COMP2(@_); # COMP2 will not be called if option c is null? } else { warn 'Error: arg -t without preceding -c: processing terminated'; die '!FINISH'; } }, '<>' => sub {print "\nThat is not a valid parameter\n";}, ); die "Error: argument processing did not complete successfully" unless($result); exit(0); sub COMP1 { print "Option -$_[0] is value=$_[1]\n"; $args{$_[0]} = $_[1]; } sub COMP2 { print "Option -$_[0] is value=$_[1]\n"; $args{$_[0]} = $_[1]; }