<?xml version="1.0" encoding="windows-1252"?>
<node id="126960" title="Any last words?" created="2001-11-22 11:50:49" updated="2005-08-15 07:04:21">
<type id="120">
perlmeditation</type>
<author id="87452">
broquaint</author>
<data>
<field name="doctext">
Playing about with [signal handlers] the other day, I came across a rather unusual caveat - when you pass multiple arguments to &lt;tt&gt;[perlfunc:die|die()]&lt;/tt&gt; or &lt;tt&gt;[perlfunc:warn|warn()]&lt;/tt&gt; they are concatenated together, whether they are strings or not, and put into the first parameter of the handlers.
&lt;code&gt;
use strict;

$SIG{'__DIE__'} = sub {
    local $" = ', ';        # this will have no effect on @errs
    my @errs = @_;
    print "$0: @errs";
    exit(1);
};
die('foo', {'bar' =&gt; 'xxx'}, ['baz','quux']);

__END__

output -

die.pl: fooHASH(0x80f9964)ARRAY(0x810a014) at die.pl line 9.
&lt;/code&gt;
This is counter-intuitive since one expects to pass a &lt;tt&gt;LIST&lt;/tt&gt; and get the same at the other end. While I am aware that [signal handlers] traditionally only take a single argument, this particular caveat is not explained in the [perlman:perlfunc|docs] (although it &lt;b&gt;alludes&lt;/b&gt; to taking a single argument, as the example code always used &lt;tt&gt;$_&amp;#091;0&amp;#093;&lt;/tt&gt; when referring to the arguments). Also, I'm fairly sure this is consistent across all platforms since the concatenation is hard-coded in the perl source (i.e no platform dependent &lt;tt&gt;#ifdef&lt;/tt&gt;'s).
&lt;p&gt;
So this is not so much a bug (as I first thought it might be) as an inconsistency between the documentation and the code. Perhaps some wisened monks out there could enlighten me as to the purpose of this 'feature' ...

&lt;p&gt;
broquaint</field>
</data>
</node>
