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


in reply to Template::Toolkit: better way to generate variable names?

Did you try this?
[% foo_1 = 'value1' foo_2 = 'value2' foo_3 = 'value3' foo_4 = 'value4' foo_5 = 'value5' %] [% FOREACH n = [ 1 .. 5 ] %] [% 'foo_' _ n %] is [% ${ "foo_$n" } %] [% END %]
Anyway, apply here the usual arguments against variable variable names. Use a hash or an array, if you can.

Update: I misread the question. See geektron's reply.