xref: /openbsd/gnu/usr.bin/perl/t/lib/Cname.pm (revision 3bef86f7)
1package Cname;
2our $Evil='A';
3
4sub 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
34sub import {
35    shift;
36    $^H{charnames} = \&translator;
37}
381;
39