So, I'll propose an array of arrays solution instead.
We're sort of simulating the ordered hashes, by having paired elements in each of the arrays. This works because we don't actually need any hash key lookups!my @tmpl_array = ( urlloopA => [ 'Home' => '/', 'Icons' => '/icons/', 'Sitedocs' => '/doc/', ], urlloopB => [ 'Cisco' => 'http://www.cisco.com/', 'CPAN' => 'http://search.cpan.org/', 'Google' => 'http://www.google.com/', 'Perl Monks' => 'http://www.perlmonks.org/', ], ); for (my $i = 0; $i < $#tmpl_array; $i+=2) { my($loop, $aref) = @tmpl_array[$i, $i+1]; my @vars; for (my $j = 0; $j < $#{$aref}; $j+=2) { my($name, $url) = @{$aref}[$j, $j+1]; push @vars, { name => $name, url => $url }; } $template->param($loop, [ @vars ]); }
Update: This code would be used with the same updated template as the hash of hashes suggestion in my earlier reply.
In reply to Re: Re: (2) Got those HTML::Template and subroutine blues (tie hash o' hashes?)
by chipmunk
in thread Got those HTML::Template and subroutine blues
by ybiC
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |