HELP_MESSAGE() and exit unless $ARGV[1]; foreach (@ARGV) { HELP_MESSAGE() and exit unless /^-?\d+$/ } # ... and later ... sub HELP_MESSAGE { print $help; } #### die $help unless $ARGV[1]; map { /^-?\d+$/ or die "Invalid input $_\n" } @ARGV;