Add display() for displaying icky scalars.
authorJarkko Hietaniemi <jhi@iki.fi>
Fri, 7 Dec 2001 14:58:06 +0000 (14:58 +0000)
committerJarkko Hietaniemi <jhi@iki.fi>
Fri, 7 Dec 2001 14:58:06 +0000 (14:58 +0000)
p4raw-id: //depot/perl@13513

t/test.pl

index ca4af68..ac6bbb7 100644 (file)
--- a/t/test.pl
+++ b/t/test.pl
@@ -263,6 +263,12 @@ sub BAILOUT {
 }
 
 
+# A way to display scalars containing control characters and Unicode.
+sub display {
+    join("", map { $_ > 255 ? sprintf("\\x{%x}", $_) : chr($_) =~ /[[:cntrl:]]/ ? sprintf("\\%03o", $_) : chr($_) } unpack("U*", $_[0]));
+}
+
+
 # A somewhat safer version of the sometimes wrong $^X.
 BEGIN: {
     eval {