This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
new perldelta
[perl5.git] / t / lib / Cname.pm
1 package Cname;
2 our $Evil='A';
3
4 sub translator {
5
6     # Returns the input as a name, except for these special ones
7
8     my $str = shift;
9     if ( $str eq 'EVIL' ) {
10         # Returns A first time, AB second, ABC third ... A-ZA the 27th time.
11         (my $c=substr("A".$Evil,-1))++;
12         my $r=$Evil;
13         $Evil.=$c;
14         return $r;
15     }
16     if ( $str eq 'EMPTY-STR') {
17        return "";
18     }
19     if ( $str eq 'NULL') {
20         return "\0";
21     }
22     if ( $str eq 'LONG-STR') {
23         return 'A' x 255;
24     }
25     # Should exceed limit for regex \N bytes in a sequence.  Anyway it will if
26     # UCHAR_MAX is 255.
27     if ( $str eq 'TOO-LONG-STR') {
28        return 'A' x 256;
29     }
30
31     return $str;
32 }
33
34 sub import {
35     shift;
36     $^H{charnames} = \&translator;
37 }
38 1;