rastoboy has asked for the wisdom of the Perl Monks concerning the following question:
As you can see, I'm collecting information about different IP's. I don't know in advance what they will be. I send the object itself to the template code, which looks like this:$VAR1 = { '10.1.7.142' => { 'counter' => 2, 'clusterstatus' => on, }, '10.1.7.11' => { 'counter' => 3, 'clusterstatus' => off, }, '10.1.7.112' => { 'counter' => 3, 'clusterstatus' => on, }, };
Which yields me:[% FOREACH ip = data %] this is ip [% ip %] counter is [% ip.counter %] [% END %]
So I expect to get "HASH(0x...)" for the $ip variable, but I don't understand why I can't access ip.counter. I've even tried making a separate hashref with a simple list of ip's in the hash and iterating through that:this is ip is HASH(0x9c68328) counter is this is ip is HASH(0x9c62e68) counter is this is ip is HASH(0x9c62d0c) counter is
and then:in the same object: 'ips' => [ '10.1.7.142', '10.1.7.11', '10.1.7.112' ],
But with that I get nothing at all, like it can't find the 'ips' key. In the past when I'm using key names that are predictable, I haven't had any trouble, but this one is kicking my behind. It appears I'm misapprehending something basic--any input would be greatly appreciated![% FOREACH ip in ips %] this is ip is [% ip %] counter is [% ip.counter %] [% END %]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Template Toolkit and unpredictable hashrefs
by ikegami (Patriarch) on Mar 29, 2010 at 01:55 UTC | |
by rastoboy (Monk) on Mar 29, 2010 at 02:05 UTC | |
by ikegami (Patriarch) on Mar 29, 2010 at 02:09 UTC | |
by rastoboy (Monk) on Mar 29, 2010 at 02:14 UTC | |
|
Re: Template Toolkit and unpredictable hashrefs
by Herkum (Parson) on Mar 29, 2010 at 14:06 UTC | |
|
Re: Template Toolkit and unpredictable hashrefs
by Mr. Muskrat (Canon) on Mar 30, 2010 at 17:16 UTC | |
by ikegami (Patriarch) on Mar 30, 2010 at 17:19 UTC |