hamidafshar has asked for the wisdom of the Perl Monks concerning the following question:

Hi brethren, I am using Perl, template toolkit and latex to write to a PDF file. I would like some way of being able to record an error log or when my PDF file shows nothing (which suggests there is an error) I like to be able to read a log that tells me what the error is. This is the code that creates the template file and prints the output:
my $vars = {title => '', rows => \@rows, inv_add => \@inv_rows}; my $temp = '/tmp/TEST_'.$inv_no.'_'.$$; my $file = $temp.".tex"; $tt->process('printInvoice.tmpl', $vars, $file) || die $tt->error(); system("Can I write something here of some use???"); print header(-type=>'application/pdf'); open(PDF, $temp.'.pdf'); while (<PDF>) { print $_; } close(PDF);
Thanks for your wisdom.

Replies are listed 'Best First'.
Re: Perl, latex and linux Error logging
by moritz (Cardinal) on Sep 12, 2011 at 09:41 UTC

    I don't know about your pdflatex, but all versions that I've used so far (miktex, texlive, xelatex) automatically wrote a .log file, which contains a transcript of the latex output.

    So system("pdlatex $other_options $filename.tex >/dev/null 2>&1"); should do, and then examine $filename.pdf.

    By the way File::Temp offers a safer and better way to generate temporary files (and file names).

      Very helpful, ta