http://qs321.pair.com?node_id=356996


in reply to Interpolating $var in a $string

This is fraught with danger, dont do this, use a template system like Text::Template, Template Toolkit, or something similar. But here's what you're trying to do.

#!/usr/bin/perl -w use strict; my $name = "Fred"; my @infile = <DATA>; my $tmpl = join '', @infile; # output print eval("qq{${tmpl}}"); __DATA__ This is my template. Here is my $name

Be warned, you can create a huge security hole by doing this.