use Attribute::Property; { package Param::function; sub new : New; # XXX - Both need anchors? sub type : Property { /Order|Return/ } sub month : Property { grep /$_[1]/, 1 .. 12 } } sub function { my $self = shift; ... } #### my %params = ( type => qr/Order|Return/, month => sub { my $month = shift; return grep { /$month/ } (1 .. 12) } ); my $param = Param::function->new(\%params); $param->type = 'Return'; $param->month = 3; print $param->type; # prints 'Return' print $param->month; # prints 3 # the following two method calls will fail (croaking) $param->type = 'Ovid'; $param->month = 13; #### my $param = @_ == 1 ? shift : Param::function->new({ @_ });