use Getopt::Long; my %OPT; GetOptions \%OPT, qw/ help|h DEBUG / or ($OPT{help} = 1); if ($OPT{DEBUG}) { # whatever you like: require Data::Dump; eval "use Carp::Always"; } ... say "Got some data:\n", Data::Dump::pp(\%my_data) if $OPT{DEBUG};