Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Re: Argument Passing, preference or performance ?

by kshay (Beadle)
on Nov 12, 2002 at 00:09 UTC ( #212158=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://212158]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2022-07-06 04:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?