in reply to Catching perl warnings and errors

In my mind, development some function for catching error and warnings is better way to have full control at your application. I mean to use try and catch. Unfortunatelly, Perl doesn't consist those function but you can implement them yourself or use existing modules from CPAN, for example Error:
use Error qw(:try); try { some code; code that might thrown an exception; more code; return; } catch Error with { my $ex = shift; # Get hold of the exception object handle the exception; } finally { cleanup code; }; # <-- Remember the semicolon
Look at Object Oriented Exception Handling in Perl for more clear understanding of how to catch exception and error in Perl.

Updated:
For insert message into Apache log you can use module Apache::Log or Sys::Syslog, Net::Syslog for console applications.

      
--------------------------------
SV* sv_bless(SV* sv, HV* stash);