[sf-perl] passing array and hash references
rdm at cfcl.com
Thu Sep 28 13:08:13 PDT 2006
> At 12:18 PM -0700 9/28/06, David Fetter wrote:
>> On Thu, Sep 28, 2006 at 12:08:55PM -0700, Rich Morin wrote:
>>> Clues, comments, suggestions?
>> Um, what is it that you want the above on? I
>> generally pass references into functions, and
>> increasingly just one reference to a hash (named
>> parameters) per Perl Best Practices. :)
I rather thought this paragraph laid out the objective:
> # Assume that you have a large body of code that was written
> # in Perl 4, using typeglobs to pass arrays and hashes into
> # functions. You want to kill off this ancient usage, moving
> # to a method that complies with "use strict". However, code
> # changes take effort and have associated risks. So, what is
> # the "minimal cost" strategy for achieving your goals?
If the problem were "how should I code something from scratch",
using a single parameter hash might be an appropriate suggestion.
However, if you are tackling a "large body of code", converting
it all to use this technique may not be feasible (let alone safe).
So, what IS the appropriate fix? My code example shows several
alternatives; is any of them the clear winner? If so, why? If
not, what other approach(es) should be considered (and why)?
http://www.cfcl.com/rdm Rich Morin
http://www.cfcl.com/rdm/resume rdm at cfcl.com
http://www.cfcl.com/rdm/weblog +1 650-873-7841
Technical editing and writing, programming, and web development
More information about the SanFrancisco-pm