Re: Read from Apache error.log
[prev]
[thread]
[next]
[Date index for 2005/03/27]
> Hello, im very new to the perl, modperl and apache combination.
>=20
So am I, but I think I have a usable solution for you.
> I am invoking another program from within my perl module using a=20
> 'System(...)' call. Although the call is successfull, there are times whe=
n=20
> the invoked program may terminate with a '=07parse error:' for example, a=
nd=20
> theses are logged in the error.log. Is there a way the catch or read this=
as=20
> it happens and display to the browser?
Here's what I do ... add the line
use Carp;
to your Module list (checkout the perldocs on it for full details)
Wrap your call in an 'eval {};' block. Example ...
eval
{
System.call (...); # This is the call that you're expecting an error =
from
}; ## Don't forget the semi-colon
if ( $@ )
{
$r->print ( "Uh oh. Error found: $@" );
carp ( $@ );
}
The eval acts as an exception handler. There is some discussion on the mod=
_perl site for using eval and Carp for exception handling.
Hope the helps.
Rodger
 |
 |
Re: Read from Apache error.log
Rodger Castle 11:59 on 27 Mar 2005
|