File Coverage

blib/lib/Lingua/31337.pm
Criterion Covered Total %
statement 6 23 26.0
branch 0 10 0.0
condition n/a
subroutine 2 3 66.6
pod 1 1 100.0
total 9 37 24.3


line stmt bran cond sub pod time code
1             package Lingua::31337;
2              
3 1     1   559 use strict;
  1         2  
  1         49  
4              
5 1     1   5 use vars qw[%EXPORT_TAGS @EXPORT $VERSION %CONVERSIONS $LEVEL];
  1         2  
  1         729  
6              
7             %EXPORT_TAGS = ( 'all' => [ qw[ text231337 ] ] );
8              
9             @EXPORT = ( @{ $EXPORT_TAGS{'all'} } );
10              
11             $VERSION = '0.02';
12              
13             $LEVEL = 5;
14              
15             %CONVERSIONS = (
16              
17             # handle the vowels
18             1 => {
19             mixcase => 0,
20             chars => {
21             a => 4,
22             e => 3,
23             i => 1,
24             o => 0,
25             },
26             },
27              
28             # Handle vowels and some consonants,
29             # don't use punctuation in the translation,
30             # shift case at random.
31             5 => {
32             mixcase => 1,
33             chars => {
34             a => 4,
35             e => 3,
36             f => 'ph',
37             i => 1,
38             l => 1,
39             o => 0,
40             's$' => 'z',
41             t => 7,
42             },
43             },
44              
45             # Handle vowels and most consonants,
46             # use punctuation in the translation,
47             # shift case at random,
48             # convert some letters.
49             7 => {
50             mixcase => 1,
51             chars => {
52             a => 4,
53             b => '|3',
54             d => '|)',
55             e => 3,
56             f => 'ph',
57             h => '|-|',
58             i => 1,
59             k => '|<',
60             l => 1,
61             'm' => '|\/|',
62             n => '|\|',
63             o => 0,
64             's$' => 'z',
65             t => '-|-',
66             v => '\/',
67             w => '\/\/',
68             x => '><',
69             },
70             },
71              
72             # Handle vowels and most consonants,
73             # use punctuation in the translation,
74             # shift case at random,
75             # convert some letters to others,
76             # decide between several options.
77             9 => {
78             mixcase => 1,
79             chars => {
80             a => [ 4, 'aw' ],
81             b => '|3',
82             ck => 'x',
83             'ck$' => 'x0rz',
84             d => '|)',
85             e => [ 3, 0, 'o' ],
86             'ed$' => 'z0r3d',
87             'er$' => '0r',
88             f => 'ph',
89             h => '|-|',
90             i => 1,
91             k => '|<',
92             l => 1,
93             'm' => '|\/|',
94             n => '|\|',
95             o => 0,
96             's' => 'z',
97             t => '-|-',
98             v => '\/',
99             w => '\/\/',
100             x => '><',
101             },
102             },
103             );
104              
105             sub text231337 {
106 0     0 1   my @text = @_;
107 0           my @new_text = ();
108            
109 0           $LEVEL-- until exists $CONVERSIONS{$LEVEL};
110            
111 0           foreach my $line ( @text ) {
112 0           foreach ( keys %{$CONVERSIONS{$LEVEL}->{chars}} ) {
  0            
113 0 0         if ( ref $CONVERSIONS{$LEVEL}->{chars}->{$_} ) {
114 0 0         $line =~ s/($_)/(0,1)[rand 2] ? @{$CONVERSIONS{$LEVEL}->{chars}{$_}}[rand $#{$CONVERSIONS{$LEVEL}->{chars}{$_}}] : $1/egi;
  0            
  0            
  0            
115             } else {
116 0 0         $line =~ s/($_)/(0,1)[rand 2] ? $CONVERSIONS{$LEVEL}->{chars}{$_} : $1/egi;
  0            
117             }
118             }
119 0 0         $line =~ s/([A-Z])/(0,1)[rand 2] ? uc($1) : lc($1)/egi if $CONVERSIONS{$LEVEL}->{mixcase};
  0 0          
120 0           push @new_text, $line;
121             }
122 0           return @new_text;
123             }
124              
125              
126             1;
127             __END__