[sf-perl] passing array and hash references

Quinn Weaver qw at sf.pm.org
Fri Sep 29 00:34:22 PDT 2006

On Fri, Sep 29, 2006 at 12:18:45AM -0700, Rich Morin wrote:
> At 11:10 PM -0700 9/28/06, Quinn Weaver wrote:
> > Rich, I have a novel solution to your problem.  It combines
> > the minimal code changes of the dereferencing approach with
> > the semantics of references.  Also, it complies with
> > warnings and strictures.
> My subscription to this list keeps on paying for itself...
> Thanks, Quinn (as well as the Man With Too Many Initials :-).
> > It requires that you modify only the subroutine call
> >
> >     t_alias (\@array, \%hash); # Use references, not globs.
> I don't see that this requires any change to the calling code.
> Although the _receiving_ code no longer uses typeglobs, the
> _calling_ code uses the same syntax it did before:
>     t_tg(\@array, \%hash);

Ah.  I was thinking the call looked like this:

      t_tg(*array, *hash);

I guess my Perl 4 skills are rusty. ;)

> This is great stuff, Quinn!

Glad you like it. :)

>  Now, before I go dancing in the
> streets, are there any caveats about performance, safety, etc?

I don't know; I've never used it in the wild.  I just read about it
in _Perl Best Practices_, and your post jogged my memory.  I hope
it helps!

qw (Quinn Weaver); #President, San Francisco Perl Mongers
=for information, visit http://sf.pm.org/weblog =cut

More information about the SanFrancisco-pm mailing list