my %defaults = ( cat => 1, dog => 2 ); my @allowed = keys(%defaults); # you might allow others in here too. sub new { my $class = shift; my %args = (%defaults, @_); my @hash{@allowed} = @args{@allowed}; # ignore arguments # that we're not expecting. # do any specific checking here. my $self = \%hash; return bless ($self, $class); }