On Wed, 2006-19-04 at 11:30 +0100, Graeme McLaren wrote: > Hi, I'm working with template loops today and I was thinking I would write a > function to pass an array of hashes to the template loop a bit like: > > $template->param(pos_colours =>colours()); > > > sub colours{ > > my @colours =( > { id => '', is_selected => > 'selected', name='none'}, > { id => '#123456', is_selected => '', name='Red' }, > { id => '#122312', is_selected => '', name='Blue' }, > { id => '#826313', is_selected => '', name='Green' } > ); > > return [EMAIL PROTECTED]; > } > > > > Is there a better way to do this, will this work? I can't test it at the > moment as the server is down :(
One way would be to make @Colours a global: my @Colours = ( ... ); ... $template->param( pos_colours => [EMAIL PROTECTED] ); -- __END__ Just my 0.00000002 million dollars worth, --- Shawn "For the things we have to learn before we can do them, we learn by doing them." Aristotle * Perl tutorials at http://perlmonks.org/?node=Tutorials * A searchable perldoc is at http://perldoc.perl.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>