Hello Monks,
I'm working with a great module Template::Extract, for get value from a non structure document, but can't see the way to resolve this, i'm need to extract many time the same information, but doesn't work, see the example:
use Template::Extract; use Data::Dumper; my $obj = Template::Extract->new; my $template = << 'TU'; <ul>[% FOREACH record %] <li><A HREF="[% url %]">[% title %]</A>: [% rate %] - [% comment %]. [% ... %] [% END %]</ul> TU my $document = <<'TY'; <ul><li><A HREF="http://slashdot.org">News for nerds.</A>: A+ - nice. this text is ignored.</li> <li><A HREF="http://microsoft.com">Where do you want...</A>: Z! - yeah +. this text is ignored, too.</li></ul> <ul><li><A HREF="http://slashdot.org">News for nerds.</A>: A+ - nice. this text is ignored.</li> <li><A HREF="http://microsoft.com">Where do you want...</A>: Z! - yeah +. this text is ignored, too.</li></ul> <ul><li><A HREF="http://slashdot.org">News for nerds.</A>: A+ - nice. this text is ignored.</li> <li><A HREF="http://microsoft.com">Where do you want...</A>: Z! - yeah +. this text is ignored, too.</li></ul> <ul><li><A HREF="http://slashdot.org">News for nerds.</A>: A+ - nice. this text is ignored.</li> <li><A HREF="http://microsoft.com">Where do you want...</A>: Z! - yeah +. this text is ignored, too.</li></ul> <ul><li><A HREF="http://slashdot.org">News for nerds.</A>: A+ - nice. this text is ignored.</li> <li><A HREF="http://microsoft.com">Where do you want...</A>: Z! - yeah +. this text is ignored, too.</li></ul> <ul><li><A HREF="http://slashdot.org">News for nerds.</A>: A+ - nice. this text is ignored.</li> <li><A HREF="http://microsoft.com">Where do you want...</A>: Z! - yeah +. this text is ignored, too.</li></ul> <ul><li><A HREF="http://slashdot.org">News for nerds.</A>: A+ - nice. this text is ignored.</li> <li><A HREF="http://microsoft.com">Where do you want...</A>: Z! - yeah +. this text is ignored, too.</li></ul> <ul><li><A HREF="http://slashdot.org">News for nerds.</A>: A+ - nice. this text is ignored.</li> <li><A HREF="http://microsoft.com">Where do you want...</A>: Z! - yeah +. this text is ignored, too.</li></ul> <ul><li><A HREF="http://slashdot.org">News for nerds.</A>: A+ - nice. this text is ignored.</li> <li><A HREF="http://microsoft.com">Where do you want...</A>: Z! - yeah +. this text is ignored, too.</li></ul> <ul><li><A HREF="http://slashdot.org">News for nerds.</A>: A+ - nice. this text is ignored.</li> <li><A HREF="http://microsoft.com">Where do you want...</A>: Z! - yeah +. this text is ignored, too.</li></ul> TY open F,'>./file.txt'; print F Dumper( $obj->run($obj->compile($template), $document) ); close F;
With this script i'm get this:
$VAR1 = { 'record' => [ { 'rate' => 'A+', 'comment' => 'nice', 'url' => 'http://slashdot.org', 'title' => 'News for nerds.' }, { 'rate' => 'Z!', 'comment' => 'yeah', 'url' => 'http://microsoft.com', 'title' => 'Where do you want...' } ] };
Why?, what can i do to retrieve more data?
Thank in advance
In reply to How template::extract works? by john32
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |