<?xml version="1.0" encoding="windows-1252"?>
<node id="21573" title="Fun with $SIG{__DIE__}" created="2000-07-07 20:41:14" updated="2005-08-04 17:58:12">
<type id="115">
perlquestion</type>
<author id="9135">
Adam</author>
<data>
<field name="doctext">
I am in the process of adding a bunch of debug commands to a script. They are of the form:&lt;code&gt;
print LOG "Some message like, \$v=$v\n" if DEBUGING;
&lt;/code&gt;
(Note that DEBUGING is a constant declared with &lt;tt&gt;use constant&lt;/tt&gt;) And I wanted to catch all those lines that said &lt;code&gt;
do this or die "couldn't do it.";
&lt;/code&gt;
by catching the die signal. But I'm not sure how to catch the message that die was called with. Does any one know?&lt;code&gt;
$SIG{__DIE__}=sub {print LOG "Script Died" and close LOG if DEBUGING};
# is what I have, but I want:
$SIG{__DIE__}=sub {print LOG "Script Died: $msg" and close LOG if DEBUGING};
&lt;/code&gt;
Thanks!</field>
</data>
</node>
