Reputation: 28447
I am currently working from home (on a Sunday!) and I am trying to figure out why my Perl script is returning NULL to PHP from where it is called. However, I don't see how I can debug the Perl script itself. The PHP file returns a warning that I am trying to do an array operation on a non-array object (because the expected array is actually NULL returned by PHP). The logs of the webserver have only logged this warning as well - no Perl errors.
Is there a place where specific 'external' logs are stored on a server? Or, is there a better way to debug a Perl file that is been run from a PHP file that is required in a main PHP file? Debugging isn't necessary (I don't need a debug mode) but I'd like to see the errors or warnings at least.
Upvotes: 2
Views: 149
Reputation: 898
You can add following code at the top of your Perl script:
sub debug_log
{
open my $log_fh, ">>", "/tmp/debug.log";
print $log_fh $_[0];
warn $_[0];
close $log_fh;
}
$SIG{__WARN__} = \&debug_log;
$SIG{__DIE__} = \&debug_log;
This way all the warnings and die
messages should end up in /tmp/debug.log
.
Upvotes: 3