package Whatever; my @required = qw[key1 key2 key3]; sub new { bless {}, shift; } sub init { my $self = shift; my %attr = @_; foreach my $required (@required) { die "Required attribute $required missing" unless exists $attr{$required}; } @$self{keys %attr} = values %attr; $self; } my $obj = Whatever::->new->init(key1=>1, key2=>2, key3=>3);
In reply to Re: Module to Check Constructors?
by JavaFan
in thread Module to Check Constructors?
by awohld
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |