Eeecck;
This:
  my $vars = {
   data => \@data,
          };
[% FOREACH item = data %]
[% FOREACH i = item %]
<tr>
 <td>item1=[% i %]</td><td>item2=[% i.id 
%]</td><td>item3=[% i.name %]</td>
</tr>
[% END %]
[% END %]

Gives me that:
item1=ARRAY(0x8368dc4) item2= item3= 
item1=ARRAY(0x8368df4) item2= item3= 
item1=ARRAY(0x8368e30) item2= item3=

Maybe my references are not what they seem? I would expect 
item2,3 to be empty because they are non-existent variables but I 
don't see why my scalars have gone. I used fetchall_arraryref to grab 
the data. Should I fetch my return value as "\@data" as well?


(my @data) = &getusers();
....
sub getusers {
......
  while (my ($id,$name,$surname) = $sth->fetchall_arrayref) {
        return $id,$name,$surname;
        }
}

Thanx.
Dp.


On 15 Oct 2002 at 7:49, Chris Winters wrote:



> On Tue, 2002-10-15 at 06:14, Dermot Paikkos wrote:
> > Hi 
> > 
> > I have a perl script (mod_perl) that connects to a DB (using 
> > APACHE:: DBI). I am trying to display 3 fields from all the records
> > in a table (about 55 records). The records come back as an array
> > reference (an array of arrays). I have been passing the arrayref to
> > my templates like so: 
> > 
> > my $file = "test.atm";
> > my $vars = {
> >             data => @data,
> >            };
> 
> The problem is that you're not passing a reference. Try instead:
> 
>  my $vars = {
>    data => \@data,
>          };
> 
> Chris
> 
> -- 
> Chris Winters ([EMAIL PROTECTED])
> Building enterprise-capable snack solutions since 1988.
> 
> 
> _______________________________________________
> templates mailing list
> [EMAIL PROTECTED]
> http://www.template-toolkit.org/mailman/listinfo/templates
> 


~~
Dermot Paikkos * [EMAIL PROTECTED]
Network Administrator @ Science Photo Library
Phone: 0207 432 1100 * Fax: 0207 286 8668


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

Reply via email to