Well, this is really a perl problem, or a my lack of understanding perl problem, but as it's come to me whilst using the Template Toolkit and as you were so helpful earlier in the day, I though I'd ask on here.
I've got a program which was written as a command line util, it outputs an array which is generated by. my @line = split ( /\s*,\s*/, $_ ); my @temp = pitchcalc ($use_length, $use_width, @line); push @results, [ $temp[0], $line[4], $line[5], $temp[1], "Watts", "£", $temp[2], "landscape", $line[6], $temp[3],"x",$temp[4]]; so a list of info, now I want to pass this through to the template so I can stick it in an html table I think the template code should look something like this [% FOREACH row IN results %] <tr> <td>[% row[0]</td> <td>[% row[1]</td> .... <td>[% row[11]</td> <tr> [% END %] But I can't work out how to pack the @results into $var as the examples I've seen all seem to do things like my $vars = { copyright => 'released under the GPL 2008', order => $order }; I've tried passing it through by doing my $vars = { copyright => 'released under the GPL 2008', result => @results }; But that doesn't seem to work, and I'm not convinced by my row[n] syntax either. I started doing some reading on the web about perl datastructures but when I got to the line "Never write $$a[$i] when you mean ${$a[$i]} or @$a[$i] when you mean @{$a[$i]}. Those won't work at all." I think my brain exploded. So if anyone can explain simply how I pass an array from the cgi to the template so I can make a table out of it that would be wonderful. It's worth pointing out that I know the number of columns in the array, but not the number of rows, the number of rows is affected by how many lines there are in the datafile, which is variable. Ideally I'd like a method of passing an arbitrary sized array and making a table out of that. tvmia M -- GPG key here. http://www.gatrell.org/gpg.public.key
signature.asc
Description: Digital signature
_______________________________________________ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates