GetOptions( '--one' => \$one, '--two' => \$two, '--three' => \$three, ); die "Only one of options --one, --two and --three are allowed\n" if ( grep defined, $one, $two, $three ) > 1; #### GetOptions( '--one' => \$opts{one}, '--two' => \$opts{two}, '--three' => \$opts{tree}, ); die "Only one of options @{[ sort keys %opts ]} are allowed\n" if ( grep defined, values(%opts) ) > 1;