#!/your/perl/here use strict; use warnings; use Getopt::Declare; our $options; $options = Getopt::Declare->new( <<'OPTIONS' ); -one First parameter { defer { reject ( $one > $two => '\$one ($one) > \$two ($two)' ) } } -two Second parameter { defer { reject ( $one > $two => '\$one ($one) > \$two ($two)' ) } } OPTIONS print "one = $options->{-one}\n"; print "two = $options->{-two}\n"; __INVOKED_WITH__ perl declare.pl -one 10 -two 20 __OUTPUT__ Error: in generated parser code: Global symbol "$two" requires explicit package name at (eval 7) line 100. Global symbol "$one" requires explicit package name at (eval 7) line 144. #### sub validate { my $options = shift; $options->{-one} = 1 unless ( exists( $options->{-one} ) ); $options->{-two} = 2 unless ( exists( $options->{-two} ) ); die "Error: -one ($options->{-one}) > -two ($options->{-two}), " if ( $options->{-one} > $options->{-two} ); } $options = Getopt::Declare->new( <<'OPTIONS' ); ... OPTIONS validate( $options );