in reply to Re: Interpolation of variables read from a file
in thread Interpolation of variables read from a file

I think Corion's method is more suitable for me :-)

But I find a "bad" way to make it, and I think this way is more efficient in mem and time :-(

File: main.pl => the main source file
require "all_hashes.pl"; # read in all the hashes our $item = "Perl"; # this $item must be global :-( require "template.pl"; # perl interpolates all the variable print $out; # $out is defined in template.pl #...
File: template.pl
my $out = "-p $act1{$item} -p $act2{$item} ...";
File: all_hashes.pl => the file contains all the hashes
my %act1 = ( "food" => "eat it", "drink" => "drink it", "Perl" => "play it"); my %act2 = ( "food" => "prepare it", "drink" => "be drunk", "Perl" => "write it"); #...
It's bad, hardcoded and has many global variables, however, a simple and fast way :-(