in reply to Template Toolkit and unpredictable hashrefs

If I were tackling such a problem, I would use a slightly different data structure.

my $ips = [ { ip => '10.1.7.142', counter => 2, clusterstatus => 'on', }, { ip => '10.1.7.11', counter => 3, clusterstatus => 'off', }, { ip => '10.1.7.112', counter => 3, clusterstatus => 'on', }, ];
Then in your template:
[% FOREACH item IN ips %] this is ip is [% item.ip %] counter is [% ip.counter %] [% END %]

Replies are listed 'Best First'.
Re^2: Template Toolkit and unpredictable hashrefs
by ikegami (Patriarch) on Mar 30, 2010 at 17:19 UTC
    One advantage of this method is that you can control the order of the records.