I believe the "$" preceding "mod_menu" is only needed during string 
interpolation.  Try this instead (note I also added semicolons to terminate 
each template directive as not doing so would have caused an additional error):

## start code

use strict;
use warnings;

use Template;

my $template = new Template;

$template->process (\*DATA) or die $template->error;
exit;

__DATA__
[% 
      SET mod_menu =
       {
          title=> "Title",
          html=> "Html text"
       };
 
       SET right_modules = [
          mod_menu
       ];

%]

[% FOREACH module = right_modules %]
      [% module.title %]
      [% module.html %]
[% END %]  

## end code

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Jason Peck
Sent: Thursday, November 18, 2004 10:09 AM
To: [EMAIL PROTECTED]
Subject: [Templates] Why can't I create a list of named hashes?


Can someone help me figure out how to create a named hash, then include
it in a named list within a template? I can't understand why the
following does not work:

[% 
       mod_menu =
       {
          title=> "Title",
          html=> "Html text"
       }
 
       right_modules = [
          $mod_menu
       ]

%]

[% FOREACH module = right_modules %]
      [% module.title %]
      [% module.html %]
[% END %]  


It produces an error:
! undef error - Template::Stash::XS: get (arg 2) must be a scalar or
listref


I also tried using \$mod_menu. In that case, I don't get an error but
nothing is printed.




-- 
Jason Peck

Focus Robotics
Tel. 603.594.3097
http://www.focusrobotics.com


_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to