http://www.perlmonks.org?node_id=1011429


in reply to Creating dynamic variables

Maybe you want a templating system instead? sprintf is the simplest one, and it could be used in your case as follows:

$foo = "hello"; my $x = "$foo%s"; my $output = sprintf $x, $y; # replaces "%s" with $y print $output;

There are many, many more templating systems, with varying easy of use and complexity. I recommend looking at simple string substitution first.