in reply to Re: Argument Passing, preference or performance ?
in thread Argument Passing, preference or performance ?
I'm not sure I agree that the gracefulness is the same. One situation that comes to mind is when you want to populate the elements of a hash with the passed arguments:
sub add_person { my %person = (); @person{qw(firstname lastname addr1 addr2 city state zip)} = @_; ... }
vs.
sub add_person { my %person = (); $person{firstname} = shift; $person{lastname} = shift; $person{addr1} = shift; $person{addr2} = shift; $person{city} = shift; $person{state} = shift; $person{zip} = shift; ... }
The first one just seems a lot cleaner to me. (Of course, in practice you might have the list of field names in a predefined array that you could loop through, but you get the idea.)
--Kevin
|
---|
In Section
Seekers of Perl Wisdom