in reply to errors in printing latex template output

For your template code to work I suspect something like [%st.address.house_number%] could work (untested).

I assume with this line "my $xml=$file;" you somehow want to read in the file contents into $xml. Not gonna happen ;-). For reading from files usually the operator "<>" is used. Normally just like this: "my @xml=<$file>;" But since the documentation of XML::Fast doesn't say anything about xml2hash parameters, it is to be feared that arrays as input don't work. So you need this:

open($file, 'formal.xml'); { local $/; my $xml= <$file>; }

Similar code is easily found by googling for "perl read file into scalar". The important thing is the undefining of $/, the input record separator (see perlvar). Because of that line endings are not recognized when reading the file and the file contents is returned as one single variable instead of an array of lines.

Replies are listed 'Best First'.
Re^2: errors in printing latex template output
by veerubiji (Sexton) on Oct 24, 2011 at 08:35 UTC

    hi, I tried as you Said like this

    open($file, 'formal.xml'); { local $/; my $xml= <$file>; }
    it given two errors like $xml and $file requires explicit package and I cleared those errors like this
    my $file; my $xml; open($file, 'formal.xml'); { local $/; $xml= <$file>; }
    but it doesn't produce any output its just blank pdf with author name. I tried using data dumper to print $xml_hash. but it doesn't contain any student word it number and regarding information in hash.then I think how it will recognize student. and also I tried to print address elements as you said
    [%st.address.house_number%]
    its also not working. its also printing as before I posted.

      Sorry, my fault. The "my" in "my $xml= <$file>;" is wrong and should be removed. Your correction should work as well. Did you notice that you use "DTC_Specification_transformed.xml" as filename instead of "formal.xml" in your corrected script?

      Use data::dumper to print out $xml as well just before converting it with xml2hash. If it contains the file contents then at least up to that point the script is working

        yes I corrected it, If I print $xml before converting to xml2hash using data::dumper it printing my original file as it is.But my output is blank pdf with authors name.