Re: Interpolate variable in a __DATA__ block



Rob Dixon wrote:
Gunnar Hjalmarsson wrote:
Trudge wrote:
I'm trying to get a script to interpolate variable values in a __DATA__ block if possible. This is a kind of alternative to a full- blown template method. I'm not sure if I can even do what I want, hence my posting here.

It can be done; see the FAQ entry

perldoc -q "expand variables"

<snip>

while (<DATA>) {
chomp;
next if $_ eq "<$data>";
last if $_ eq "</$data>";
s/(\$\$\w+)/$1/eeg;
print "$_\n";
}

Of course it can be done explicitly, but I assume the OP was asking if it could be done implicitly, as if it were in double quotes.

Maybe, maybe not. The FAQ says it can be done, and I just applied the solution it provides.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
.