[Templates] Retrieve stack value having '.' in the key

Paul Seamons mail@seamons.com
Sat, 16 Sep 2006 22:32:43 -0600


> Neither of those works for me in 2.14. Is this new to 2.15 maybe?
>
> -- Josh

Hmm guess I assumed to much.  I've done that very thing with strings in TT2 
all the time.  Doing a little testing we get the following:

perl -e 'use Template; Template->new->process(\qq{([% n="a b"; \$n %])([% 
\${"a b"} %])\n},{"a b"=>"z"})'
(z)(z)

perl -e 'use Template; Template->new->process(\qq{([% n="a!\@#%^&*()b"; 
\$n %])([% \${"a!\@#%^&*()b"} %])\n},{"a!\@#%^&*()b"=>"z"})'                            
(z)(z)

perl -e 'use Template; Template->new->process(\qq{([% n="a.b"; \$n %])([% 
\${"a.b"} %])\n},{"a.b"=>"z"})'
()()

perl -e 'use CGI::Ex::Template; CGI::Ex::Template->new->process(\qq{([% 
n="a.b"; \$n %])([% \${"a.b"} %])\n},{"a.b"=>"z"})'
(z)(z)

So I was right and wrong.  The notation I gave works very well in TT2 - so 
long as you don't embed periods.  I don't know what is going on in the 
internals - but it seems sort of silly that only the period has issues.  Once 
a name is looked up, it should be able to be used to access the stash 
directly.  And all names do - just don't include the period.

So - I'm afraid my help on the original question is no help at all.

Paul Seamons