use strict; use warnings; use Carp; use Getopt::Long qw(GetOptions); sub bb { GetOptions( foo => \my $foo, ) or die "Bad option"; carp "Uh oh!"; } bb(@ARGV);