in reply to passing subroutine args as a hash: why not?
As an aside, am I committing the sin of premature optimization if I worry that passing as a hash is less efficient than passing as a hashref? I mean, doesn't this:
my %params = ( param1 => 'thing', param2 => 'other thing', # bunches o' stuff param61 => 'whew!', ); initialize_object(%params); # later ... sub initialize_object { my %params = @_; # do something useful, presumably }
actually copy all 61 parameters not once but twice? As opposed to:
my $params = { param1 => 'thing', param2 => 'other thing', # bunches o' stuff param61 => 'whew!', }; initialize_object($params); # later ... sub initialize_object { my ($params) = @_; # do something useful, presumably }
? I noticed some people preferred hashref's to hashes, but no one mentioned this as a reason ... is the overhead too little to fret about really?
Just curious.
|
|---|