in reply to Re: Dynamic variable naming in Template Toolkit
in thread Dynamic variable naming in Template Toolkit

Right, I've read it. What I want to be able to do based on my understanding of the docs is something like:

[% var_name = 'foo'; $var_name = 'bar'; # I wish $foo would eq 'bar' but it doesn't %]

but my understanding is that:

[% var_name = 'foo' %]

is the same as:

[% $var_name = 'foo' %]

Right? So far I'm thinking that I can't achieve what I want. Fortunately this is Perl, so there's always another way :)

perl -e 'split//,q{john hurl, pest caretaker}and(map{print @_[$_]}(joi +n(q{},map{sprintf(qq{%010u},$_)}(2**2*307*4993,5*101*641*5261,7*59*79 +*36997,13*17*71*45131,3**2*67*89*167*181))=~/\d{2}/g));'

Replies are listed 'Best First'.
Re^3: Dynamic variable naming in Template Toolkit
by perrin (Chancellor) on May 31, 2007 at 15:37 UTC
    Try ${var_name} = 'bar', and if that doesn't work, ask on the TT mailing list. I think TT supports this.

      That did it, in fact the code I posted above:

      [% var = 'foo'; $var = 'bar'; # now $foo eq 'bar'! %]

      actually works without the braces, I found a typo in my code :P

      perl -e 'split//,q{john hurl, pest caretaker}and(map{print @_[$_]}(joi +n(q{},map{sprintf(qq{%010u},$_)}(2**2*307*4993,5*101*641*5261,7*59*79 +*36997,13*17*71*45131,3**2*67*89*167*181))=~/\d{2}/g));'