sub new { my ( $class, @attributes ) = @_; my $self = {@attributes}; # make sure we got valid argument keys if ( @attributes ) { my $key_hash = {@attributes}; my @keys = keys %$key_hash; my @invalid_attribute_key = grep { my $tested_attributes = $_; not grep { $tested_attributes eq $_ } qw(attribute_1 attribute_2 attribute_3); } @keys; croak "invalid attribute key(s) in constructor: @invalid_attri +bute_key" if @invalid_attribute_key; } bless $self, $class; return $self; }
In reply to Module to Check Constructors? by awohld
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |