SPUG: derefencing hash reference / parsing config file (con't)

Andrew Sweger andy at n2h2.com
Sat Jan 8 15:00:28 CST 2000


On Jan 8, 2000 @ 12:46pm, Andrew Sweger wrote:

> > So, like I said above, I think this is related to Camel p. 256 and
> > Cookbook p.148, hard references don't work as hash keys.
> 
> That's not entirely true (more later). In your example above, it is not
> the case that you used a reference as a key. There's also some confusion
> above on the difference between %models and $models. You've assign the
> result of the eval to the scalar $models which is the reference to a hash.
> Later you loop over the keys of the hash %models. The two are not quite
> related. In the foreach loop, use %$models to get the hash referenced by
> the scalar $models.

I forgot to mention, you may want to use Data::Dumper when playing with
nested ref structures in Perl. Very handy. And if I had used it properly
and was paying attention, I would have seen my original mistake and not be
publicly embarrassed by El JoPe Magnifico.

use Data::Dumper;

print Dumper $someref;

I need to get out of the house...

-- 
  Andrew Sweger <andy at n2h2.com>  |  N2H2, Incorporated
  v=206.336.2947 f=206.336.1541  |  900 Fourth Avenue, Suite 3400
     Advanced Technologies       |  Seattle WA 98164-1059
          Development            |  http://www.n2h2.com/



 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    POST TO: spug-list at pm.org        PROBLEMS: owner-spug-list at pm.org
 Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
 SUBSCRIBE/UNSUBSCRIBE: Replace ACTION below by subscribe or unsubscribe
        Email to majordomo at pm.org: ACTION spug-list your_address





More information about the spug-list mailing list