use Getopt::Std; ... &parse_commandline; ... sub parse_commandline { my $funcName = (caller(0))[3]; print "\nWorking in function: $funcName\n" if $DEBUG; # c: require different config file (requires param) # q: quiet or cron mode # t: test mode (don't do anything. Just run through the motions) # v: verbose mode (same as debug) # V: version information. # d: debug mode (extra output) # h: help getopts('c:qtrvVdh',\%ARGS); ## <- here is the hash ref! # From there I just check the hash{switch} # to see if what I want is there and set # script environment accordingly. $DEBUG = 1 if ( exists $ARGS{'v'} ); $DEBUG = 1 if ( exists $ARGS{'d'} ); $NO_RULE_OUTPUT = 1 if ( exists $ARGS{'r'} ); &version if ( exists $ARGS{V} ); &funcUsage if ( exists $ARGS{h} ); if ( defined $ARGS{'c'} ) { if ( ! &check_for_valid_conf($ARGS{'c'}) ) { print "\n$config_file: Invalid config file specified on ". "command line\n"; &funcUsage } else { $config_file = $ARGS{'c'}; } } $CRON_MODE = 1 if ( exists $ARGS{'q'} ); $TEST_MODE = 1 if ( exists $ARGS{'t'} and !$CRON_MODE ); }