foreach my $f (@files) { my $config = Config::YAML::Tiny->new( config => $f ); my @template_file = split( / /, $config->get_template ); foreach my $tf (@template_file) { my @fields = split( / /, $config->get_fields ); for my $v ( @fields ) { no strict 'refs'; *{"T::$v"}= \$config->{$v}; } my $template = Text::Template->new( TYPE => 'FILE', SOURCE => $tf ) or die "Couldn't construct template: $Text::Template::ERROR"; my $result = $template->fill_in( PACKAGE => 'T', PREPEND => 'use strict;' ); ...