my $needed_param = 'need_default'; my $debug = 0; # default value numeric and not "" # getting params with getopt with a strict syntax # id est: if GetOptions fail may be better the program does NOT run at all &help()if( ! GetOptions( 'needed=s' => \$needed_param, # [..] 'd=i' => \$_debug ) or ! $needed_param ); #then adjust values to a default or a maximum as needed $debug > 3 ? $debug = 3 : $debug ; sub help { "$0 -n [-d [0-3]] ... "}