in reply to Passing hash reference to a subroutine

perldata says your typeglob method "used to be the preferred way to pass arrays and hashes by reference into a function, but now that we have real references, this is seldom needed." And, "Much safer is to use a reference."

And your typeglob method doesn't play nicely with strict and warnings, while the reference method does.

And for opinion, I think the reference method is absolutely clear; while the * introduces a bit of mystery.

  • Comment on Re: Passing hash reference to a subroutine

Replies are listed 'Best First'.
Re^2: Passing hash reference to a subroutine
by tlk00 (Initiate) on Feb 20, 2009 at 14:54 UTC
    First of all, thank you for taking the time to respond. What looked 'funny' to me was the $ { $myref } {$key}. I think I need to take some time to review the 'Programming Perl' book. Specifically Chapter 2 on subroutines and Chapter 4 on References and Nested Data Structures.
    Regards, Terry Kummell

      You could dereference that without the braces: $$myref{$key}.

      Also, map is good for your printing:

      print map { "$_=$$myref{$_}\n" } sort keys %$myref;