Re: help needed in template toolkit module
Chad Wallace <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.template-toolkit |
|---|---|
| Organization | The Lodging Company |
| Message-ID | <[email protected]> |
On Tue, 1 Nov 2011 12:40:17 +0100 veeru reddy <[email protected]> wrote: > I used XML::Simple to store this data into one hash data structure > variable $data and that information is like this > > $var1={ > university=>{ > 'name'=>'svu', > 'location'=>'ravru', > 'branch'=>{ > 'electronics'=>{ > 'student'=>[ [...] > > by using template tool kit and pdflatex compiler I am generating PDF > file , I written like this as shown below. > > my $template = Template->new(); > my $filename = 'output.tex'; > $template->process(\*DATA, $data, $filename) > || die "Template process failed: ", $template->error(), "\n"; > > system( "pdflatex $filename" ); [...] > > But I getting Different output rather than what I want. > After executing this script I am getting output when I have three or > more students in electronics and two or more semesters for each > student then only I am getting. otherwise it does print any thing > just printing studentdata: three times . for example if I have one > student with one semester in university at that situation it doesn't > give any thing it printing like this > studentdata: > studentdata: > studentdata: You didn't include the call to XML::Simple, but I have a feeling the problem is that you need to use ForceArray in XML::Simple, and then traverse the expected arrays. Without ForceArray, you'll sometimes get an array of hashes and sometimes just a hash (if there's only one). The man page for XML::Simple will explain it all. Also, reposting the same message to the same list is not going to be effective. It's likely to cause other posters to actively ignore you when they may otherwise have tried to help. If you have more information, it's best to reply to the original thread and include only the new information.