Tweaks to constant.pm
[p5sagit/p5-mst-13.2.git] / lib / Carp.pm
index 7c8932c..c0cfe08 100644 (file)
@@ -68,8 +68,15 @@ sub longmess {
              }
              for (@a) {
                $_ = "undef", next unless defined $_;
-               s/'/\\'/g;
-               substr($_,$MaxArgLen) = '...' if $MaxArgLen and $MaxArgLen < length;
+               if (ref $_) {
+                 $_ .= '';
+                 s/'/\\'/g;
+               }
+               else {
+                 s/'/\\'/g;
+                 substr($_,$MaxArgLen) = '...'
+                   if $MaxArgLen and $MaxArgLen < length;
+               }
                $_ = "'$_'" unless /^-?[\d.]+$/;
                s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;
                s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;
@@ -82,9 +89,9 @@ sub longmess {
        $error = "called";
     }
     # this kludge circumvents die's incorrect handling of NUL
-    my $msg = $mess ||= $error;
-    $msg =~ s/\0//g;
-    return $msg;
+    my $msg = \($mess || $error);
+    $$msg =~ tr/\0//d;
+    $$msg;
 }
 
 sub shortmess {        # Short-circuit &longmess if called via multiple packages
@@ -116,9 +123,9 @@ sub shortmess {     # Short-circuit &longmess if called via multiple packages
                if(defined @{$pack . "::ISA"});
        }
        else {
-            # this kludge circumvents die's incorrect handling of NUL
-           (my $msg = "$error at $file line $line\n") =~ s/\0//g;
-            return $msg;
+           # this kludge circumvents die's incorrect handling of NUL
+           (my $msg = "$error at $file line $line\n") =~ tr/\0//d;
+           return $msg;
        }
     }
     continue {