use Params::Validate qw/:all/; # MyModule->new(foo => 'val1', bar => 'val2') sub new { my $class = shift; my %args = validate(@_, { foo => 1, bar => 0 }); # foo required; bar optional ... }