http://www.perlmonks.org?node_id=827897


in reply to Re: Learning Template Toolkit Module
in thread Learning Template Toolkit Module

Yea, I've been digging through the documentation on the site, but so far it's not all that helpful. Great on making the templates work, but not so much for getting it to go to a file instead of STDOUT. Either that or I'm missing it.

I know the answer is probably something unbelievably simple, but I am just learning Perl, too, so I do sometimes need the obvious pointed out to me.

Here, let me include the (short) code I am playing with as a learning exercise ATM:
#!/usr/bin/perl -w
use Template;
my %info = ( ProjName => 'Test Project',
DocName => 'Test Document' );
print ("Hello!\n");
open(INPUT,"start.pm") || die "Can't open input file: $!";
open(OUTPUT,">testout.txt") || die "Sorry, no can do: $!";
while(<INPUT>) {
print OUTPUT $_;
}
my $tt = Template->new;
$tt -> process('template', \%info) || die $tt->error;
print OUTPUT $tt;
close(INPUT) || die "Can't close input : $!";
close(OUTPUT) || die "Can't close output : $!";

Comments on anything else I could be doing better are, of course, appreciated as well.

Thanks again!
Kaiti