xref: /openbsd/gnu/usr.bin/perl/t/lib/Cname.pm (revision 76d0caae)
1package Cname;
2our $Evil='A';
3
4sub translator {
5    my $str = shift;
6    if ( $str eq 'EVIL' ) {
7        # Returns A first time, AB second, ABC third ... A-ZA the 27th time.
8        (my $c=substr("A".$Evil,-1))++;
9        my $r=$Evil;
10        $Evil.=$c;
11        return $r;
12    }
13    if ( $str eq 'EMPTY-STR') {
14       return "";
15    }
16    if ( $str eq 'NULL') {
17        return "\0";
18    }
19    if ( $str eq 'LONG-STR') {
20        return 'A' x 255;
21    }
22    # Should exceed limit for regex \N bytes in a sequence.  Anyway it will if
23    # UCHAR_MAX is 255.
24    if ( $str eq 'TOO-LONG-STR') {
25       return 'A' x 256;
26    }
27    return $str;
28}
29
30sub import {
31    shift;
32    $^H{charnames} = \&translator;
33}
341;
35