in reply to Re: Re: Passing hashes to subs?
in thread Passing hashes to subs?

Yes, that's why I suggested the second approach using references. But I neglected to point out the dangers to the original poster. Thanks!

FWIW, I do like to use it if (and only if...) the function is designed to receive only named parameters. E. g.

sub create { my $self = shift; my %p = @_; print "$p{color} p{animal}" for (1..$p{count}); } $zoo->create(animal => 'camel', count => '10', color => 'green');

One could opt to create the zoo using a hash reference as in

$zoo->create({animal => 'monkey', ...});

but I guess that is a matter of style.