Re: Interpolate variable in a __DATA__ block
- From: noreply@xxxxxxxxx (Gunnar Hjalmarsson)
- Date: Sat, 29 Mar 2008 22:05:23 +0100
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;
if ($_ eq "<$data>")
{
next;
print "$_\n";
}
if ($_ eq "</$data>")
{
last;
}
print "$_\n";
}
Try to replace that with:
while (<DATA>) {
chomp;
next if $_ eq "<$data>";
last if $_ eq "</$data>";
s/(\$\$\w+)/$1/eeg;
print "$_\n";
}
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
.
- Follow-Ups:
- Re: Interpolate variable in a __DATA__ block
- From: Rob Dixon
- Re: Interpolate variable in a __DATA__ block
- From: Trudge
- Re: Interpolate variable in a __DATA__ block
- References:
- Interpolate variable in a __DATA__ block
- From: Trudge
- Interpolate variable in a __DATA__ block
- Prev by Date: Automate a search query from a website
- Next by Date: Re: Interpolate variable in a __DATA__ block
- Previous by thread: Re: Interpolate variable in a __DATA__ block
- Next by thread: Re: Interpolate variable in a __DATA__ block
- Index(es):
Relevant Pages
|