fields: value pos template: mytemplate_french.tmpl mytemplate_german.tmpl value: the value of pos pos: 3 #### C'est un exemple: {$value} est {$pos} #### 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; } } #### ... my @fields = split( / /, $config->get_fields ); my @vars = map {'$' . $_} @fields; my $str_var = join(" ", @vars); my $template = Text::Template->new( TYPE => 'FILE', SOURCE => $tf, PREPEND => 'use strict; use vars eval($str_var); ', ) or die "Couldn't construct template: $Text::Template::ERROR"; #### my $template = Text::Template->new( TYPE => 'FILE', SOURCE => $tf, PREPEND => 'use strict; use vars qw($value $pos); ',