In the scripts that I've been writing recently (data-munging under the guise of ETL), I've been opening an error log and then using that everywhere to log stuff as I go through.
So, you could use this approach by replacing# Somewhere early on, so that it can be used everywhere. my $error_log; ... # I don't use 'or die' here because I use autodie. open ( $error_log, '>', 'errors.log' ); ... # Later, wherever it's necessary .. print $error_log "$unique_identifier" . "$useful_variables $more useful variables\n";
in your own die case withsystem qq(echo "$message" >> log.err);
Exiting the program will close the error log filehandle. Then you can tail the error log and see what happened.print $error_log "$message\n";
There's another debate as to the necessity of crafting your own die handler .. but I'll leave that question unasked.
In reply to Re: how i capture a script error to a file ?
by talexb
in thread how i capture a script error to a file ?
by gabrielsousa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |