This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
lib/locale.t: Fail more gracefully
authorKarl Williamson <khw@cpan.org>
Mon, 22 Jun 2015 16:22:34 +0000 (10:22 -0600)
committerKarl Williamson <khw@cpan.org>
Wed, 29 Jul 2015 04:15:53 +0000 (22:15 -0600)
If a character's name is unknown, say that instead of an unitialized
warning.

lib/locale.t

index 1ebd0ce..1b510d2 100644 (file)
@@ -848,7 +848,8 @@ sub disp_str ($) {
             }
             else {
                 $result .= "  " unless $prev_was_punct;
-                $result .= charnames::viacode(ord $char);
+                my $name = charnames::viacode(ord $char);
+                $result .= (defined $name) ? $name : ':unknown:';
                 $prev_was_punct = 0;
             }
         }