use strict; use Text::Template; use Config::YAML::Tiny; my @files = map glob($_), @ARGV; my $usage = <new( config => $f ); my @template_files = split( / /, $config->get_template ); foreach my $tf (@template_files) { my @fields = split( / /, $config->get_fields ); my $template = Text::Template->new( TYPE => 'FILE', SOURCE => $tf, ', ) or die "Couldn't construct template: $Text::Template::ERROR"; my %data; for my $f (@fields) { $data{$f} = $config->{$f}; } my $result = $template->fill_in( HASH => \%data); # mytemplate_french.tmpl -> mytemplate_french.txt $tf=~s/\.tmpl//; open( my $out_file, ">$tf.txt" ); if ( defined $result ) { print $out_file $result; print "$tf.txt\n"; } else { print $Text::Template::ERROR; } close $out_file; } }