in reply to Default values in functions arguments
Passing in a list like you have won't let you do the nice list slice operation, and it's possible to pass in new values than what are defined.sub new { my $class = shift; my $hash_ref = shift; my $self = { value => '100', color => 'charcoal', }; @$self{keys %$hash_ref} = (values %$hash_ref) if (defined %$hash_r +ef); bless($self, $class); }
Still, it's a pretty nice technique, and there's no reason it has to be limited to constructors. In your case, it just might work.
|
---|