aardvark has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to use some of the command line tools of the xml.apache.org project; Xerces-J, Xalan and FOP. The goal is to validate the XML, transform it, then create a PDF. I wish I could use AxKit, but I need to create PDFs and FOP is the only open source tool I could find to do this. One of the routines look like this;
It does the job, but I am going crazy trying to trap any errors or warnings. When there is an error it just prints it to the screen and it never gets into $@. I have read up on eval and system but I cannot figure out a way to get the results of the command into $@. I need to do error checking and logging for each of these routines. Is it a problem specific to Java commands, am I missing something in my eval? Or did I just drink too much coffee today? If anybody can help me I will toast to your collective honor and wisdom this weekend. mmmmmm ... toastsub validate_xml { my $file_r = shift; # use Xerces to validate xml eval { `java sax.SAXCount -v $$file_r`; }; if ($@) { print "$@\n"; &log_error($@); } }
Get Strong Together!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (tilly) 1: Trapping Java Errors
by tilly (Archbishop) on Mar 31, 2001 at 20:12 UTC | |
|
Re: Trapping Java Errors
by MeowChow (Vicar) on Mar 31, 2001 at 02:14 UTC | |
by aardvark (Pilgrim) on Mar 31, 2001 at 02:51 UTC | |
|
(jeffa) Re: Trapping Java Errors
by jeffa (Bishop) on Mar 31, 2001 at 02:16 UTC |