punkish has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w BEGIN { $0 =~ /^(.*)\\([^\\]*)\.pl$/; our ($path, $script_name) = ($1, $2); open(STDERR, ">>$path/$script_name.err") or die "invisible error"; warn "$0 started ".localtime().$/; }
prints out to the file ?.err any errors or warnings that the script migh encounter during compile time.
My question is -- is there a way to implement a corresponding FINISH block (as opposed to __END__) which will trap any errors in case the script comes to a dead halt?
Now, I can use the die statement whenever something goes wrong, but that can't really trap things like Control-breaks or control-c etc. How do I trap SIGTERM so that the reason for SIGTERM is written out to ?.err as well?
Update: I should mention -- I need to do this on Windows.
Considered by dragonchild - Retitle to "How do I trap signals on Win32"
Unconsidered by castaway - Keep/Edit/Delete: 8/19/0 - Its fine as is, no putting words in the OPs mouth
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Implementing the counterpart of BEGIN
by Crian (Curate) on Feb 03, 2005 at 15:20 UTC | |
by punkish (Priest) on Feb 03, 2005 at 15:41 UTC | |
|
Re: Implementing the counterpart of BEGIN
by Anonymous Monk on Feb 03, 2005 at 15:38 UTC |