I've seen something similar with constructors. A hash is set up with default values, and the constructor can take a hash or hash ref as an argument.
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);
}
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.
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.