in reply to Re: (2) Got those HTML::Template and subroutine blues (chipmunk++)
in thread Got those HTML::Template and subroutine blues
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: (2) Got those HTML::Template and subroutine blues (tie hash o' hashes?)
by repson (Chaplain) on Dec 31, 2000 at 05:38 UTC |