sub verify_args { my $defaults = shift; # leave the rest of @_ intact. # Verify that args came in pairs. croak "Expecting key => value pairs, but got odd number of args" if @_ % 2; # Verify keys, ignore values. while (@_) { my ($var, undef) = (shift, shift); croak "Invalid parameter: '$var'" unless exists $defaults->{$var}; } }