If I understand your question correctly I would take a look at: Template::Plugin::Datafile Which I believe comes with TT.
http://search.cpan.org/~abw/Template-Toolkit-2.19/lib/Template/Plugin/Datafile.pm On Mon, Mar 10, 2008 at 11:07:20AM -0700, Rick wrote: > Currently I'm creating the $csv_data by running the above perl script from > the command line. Then I'm using ttree to process the templates. I know this > is awkward, which is why I posted here. > > I think that I should call the perl script from within TT2, creating > $csv_data which can then be used by other templates. Is that right? If so, > what is the best way to call a perl script from TT2? Also, if I then run > that script and generate $csv_data from within a preprocessed template, is > that data accessible to other templates? > > Hoping I'm making sense... > > Rick > > On Mon, Mar 10, 2008 at 9:12 AM, Jonathan Rockway <[EMAIL PROTECTED]> wrote: > > > * On Mon, Mar 10 2008, Rick wrote: > > > Hi all. I'm kinda new to TT2, perl, and programming. My first perl > > script was > > > required to read a csv file (from an excel spreadsheet) and write to a > > template > > > with the corresponding data structure (an array of arrays), which I > > could then > > > preprocess and access from other templates. The following script worked > > just > > > fine. However, I would appreciate comments on other (better) ways to > > accomplish > > > the same purpose, either in perl or within TT2 itself. (Any perl wisdom > > > appreciated). Thanks. > > > > I'm confused as to why you're dynamically generating the template. The > > template should be a static entity you pass data to: > > > > my $csv_data = [ [ 'foo', 'bar', 'baz' ], ['a', 'b', 'c'] ]; > > > > And then: > > > > [% FOREACH row IN csv_data %] # row = [qw/foo bar baz/] and then [qw/a > > b c/] > > <tr> > > [% FOREACH column IN row %] # column = 'foo', then 'bar', ... > > <td>[% column | html %]</td> > > [% END %] > > </tr> > > [% END %] > > > > Regards, > > Jonathan Rockway > > > _______________________________________________ > templates mailing list > templates@template-toolkit.org > http://mail.template-toolkit.org/mailman/listinfo/templates -- Kenneth Ekdahl ([EMAIL PROTECTED]) http://sensei.nu http://blog.sensei.nu _______________________________________________ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates