[sf-perl] passing array and hash references

David Fetter david at fetter.org
Thu Sep 28 16:55:41 PDT 2006

On Thu, Sep 28, 2006 at 01:08:13PM -0700, Rich Morin wrote:
> > 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?

D'oh.  My bad.

> 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)?

At some point, a body of perl4 code is going to need invasive changes
on a large scale, just as C89 or Fortran66 code would.  Those changes
will get larger and more expensive the longer it remains unmaintained.

I wish I had some kind of silver bullet here, but I suspect that
anything short of a rewrite for perl5.8x is going to be more expensive
than just doing the maintenance this code hasn't had.

David Fetter <david at fetter.org> http://fetter.org/
phone: +1 415 235 3778        AIM: dfetter666
                              Skype: davidfetter

Remember to vote!

More information about the SanFrancisco-pm mailing list