Carp with multiple arguments
authorM.J.T. Guy <mjtg@cus.cam.ac.uk>
Sat, 8 Mar 1997 20:12:17 +0000 (20:12 +0000)
committerChip Salzenberg <chip@atlantic.net>
Thu, 6 Mar 1997 16:01:12 +0000 (04:01 +1200)
Subject: Carp with multiple arguments (and lack of tests)

carp/croak/confess are documented as similar to warn/die, but whereas
warn/die print multiple arguments, carp/croak/confess print only the
first.    Assuming that this is a bug rather than a feature, the following
patch corrects it.   (And if it _is_ a feature, the pod needs updating
instead, to explain it away.)

Trying to be polite, I thought I'd update the Carp tests to cover this
case.    But I couldn't find any Carp tests ...    I'll have a go
at rectifying this lacuna.   But not till tomorrow.

p5p-msgid: E0w3STZ-0007RW-00@taurus.cus.cam.ac.uk

lib/Carp.pm

index de58648..ec08d30 100644 (file)
@@ -37,7 +37,7 @@ require Exporter;
 @EXPORT = qw(confess croak carp);
 
 sub longmess {
-    my $error = shift;
+    my $error = join '', @_;
     my $mess = "";
     my $i = 1 + $CarpLevel;
     my ($pack,$file,$line,$sub,$hargs,$eval,$require);
@@ -85,7 +85,7 @@ sub longmess {
 }
 
 sub shortmess {        # Short-circuit &longmess if called via multiple packages
-    my $error = $_[0]; # Instead of "shift"
+    my $error = join '', @_;
     my ($prevpack) = caller(1);
     my $extra = $CarpLevel;
     my $i = 2;