>>>>> "Franco" == Franco Bagnoli <[EMAIL PROTECTED]> writes:
Franco> Is there any simple way of extracting the hash of variables
Franco> from a tt2 document? I mean: using a document to define
Franco> variables for a perl program in the same way one can use an
Franco> xml document and XML::Simple to convert the xml structure into
Franco> a perl structure. I am able to obtain a copy of the stash, but
Franco> it also contains other keys, which have to be stripped off.
Franco> I think I can solve the problem, but I would like to know if
Franco> there is a ready solution.
Will this suffice?
use Template;
my %data;
my $t = Template->new();
$t->process(\<<END, { data => \%data });
[%
data.left = 'left';
data.right = [ 'this', 'thing', { goes => 'here' } ];
-%]
END
use Data::Dumper;
print Dumper(\%data);
==>
$VAR1 = {
'left' => 'left',
'right' => [
'this',
'thing',
{
'goes' => 'here'
}
]
};
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!