in reply to Re: Argument Passing, preference or performance ?
in thread Argument Passing, preference or performance ?
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
|
|---|