Hi Monks!
I'm having a devil of a time comprehending what Template::Toolkit wants from me. I have an object that resembles 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,
},
};
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:
[% FOREACH ip = data %]
this is ip [% ip %] counter is [% ip.counter %]
[% END %]
Which yields me:
this is ip is HASH(0x9c68328) counter is
this is ip is HASH(0x9c62e68) counter is
this is ip is HASH(0x9c62d0c) counter is
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:
in the same object:
'ips' => [
'10.1.7.142',
'10.1.7.11',
'10.1.7.112'
],
and then:
[% FOREACH ip in ips %]
this is ip is [% ip %] counter is [% ip.counter %]
[% END %]
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!