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


in reply to How do I avoid double substitution when replacing many patterns?

You might want to take a look at Data::Phrasebook, as this handles things a little better. Using your example the following works:

use Data::Phrasebook; my $pb = Data::Phrasebook->new( file => 'phrases.txt' ); my $str = $pb->fetch( 'baz', {foo => '${bar}', bar => '${foo}'} ); # $str = 'foo is ${bar} and bar is ${foo}'

where phrases.txt use the default parameter substitution and looks like:

baz=foo is :foo and bar is :bar

While there is support for TT style parameter substitution, it doesn't current support a TT embeded templating system. Might be a possibility for the future, but would be a little overkill for this problem ;)

--
Barbie | Birmingham Perl Mongers user group | http://birmingham.pm.org/