use Getopt::Long; GetOptions( "timeout|t=i" => \my $timeout, "help|h|?" => \my $show_help ) or die "bad options."; $timeout ||= 30; if ( $show_help ) { print "Showing help\n"; error_info(); }