--- trunk2/lib/WebPAC.pm 2004/09/05 21:40:57 410 +++ trunk2/lib/WebPAC.pm 2004/09/05 22:22:37 411 @@ -775,6 +775,38 @@ return $out; } +=head2 output_file + +Create output from in-memory data structure using Template Toolkit template +to a file. + + $webpac->output_file( + file => 'out.txt', + template => 'text.tt', + data => @ds + ); + +=cut + +sub output_file { + my $self = shift; + + my $args = {@_}; + + my $log = $self->_get_logger(); + + $log->logconfess("need file name") if (! $args->{'file'}); + + $log->debug("creating file ",$args->{'file'}); + + open(my $fh, ">", $args->{'file'}) || $log->logdie("can't open output file '$self->{'file'}': $!"); + print $fh $self->output( + template => $args->{'template'}, + data => $args->{'data'}, + ) || $log->logdie("print: $!"); + close($fh) || $log->logdie("close: $!"); +} + =head2 apply_format Apply format specified in tag with C and