line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package POE::Filter::KennySpeak; |
2
|
|
|
|
|
|
|
$POE::Filter::KennySpeak::VERSION = '1.02'; |
3
|
|
|
|
|
|
|
#ABSTRACT: Mmm PfmPpfMpp Mpfmffpmffmpmpppff fmpmfpmmmfmp fmppffmmmpppfmmpmfmmmfmpmppfmm fmpppf mmmpppmpm mpfpffppfppm PmpmppppppppffmFmmpfmmppmmmpmp |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
1560
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
50
|
|
6
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1741
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
9
|
use base qw(POE::Filter); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1577
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $kenny = _generateKenny(); # encoding table |
11
|
|
|
|
|
|
|
my $dekenny = _generateDeKenny($kenny); # decoding table |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
1
|
|
|
1
|
1
|
11782
|
my $class = shift; |
15
|
1
|
|
|
|
|
6
|
my %opts = @_; |
16
|
1
|
|
|
|
|
9
|
$opts{lc $_} = delete $opts{$_} for keys %opts; |
17
|
1
|
|
|
|
|
5
|
$opts{BUFFER} = []; |
18
|
1
|
|
|
|
|
11
|
return bless \%opts, $class; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub get_one_start { |
22
|
2
|
|
|
2
|
1
|
44804
|
my ($self, $raw) = @_; |
23
|
2
|
|
|
|
|
10
|
push @{ $self->{BUFFER} }, $_ for @$raw; |
|
16
|
|
|
|
|
42
|
|
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub get_one { |
27
|
18
|
|
|
18
|
1
|
104
|
my $self = shift; |
28
|
18
|
|
|
|
|
26
|
my $events = []; |
29
|
|
|
|
|
|
|
|
30
|
18
|
|
|
|
|
20
|
my $event = shift @{ $self->{BUFFER} }; |
|
18
|
|
|
|
|
36
|
|
31
|
18
|
100
|
|
|
|
74
|
if ( defined $event ) { |
32
|
16
|
|
|
|
|
128
|
my $record = _translate($event,1); |
33
|
16
|
50
|
|
|
|
53
|
push @$events, $record if $record; |
34
|
|
|
|
|
|
|
} |
35
|
18
|
|
|
|
|
44
|
return $events; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub get_pending { |
39
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
40
|
0
|
|
|
|
|
0
|
return $self->{BUFFER}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub put { |
44
|
2
|
|
|
2
|
1
|
18354
|
my ($self, $events) = @_; |
45
|
2
|
|
|
|
|
8
|
my $raw_lines = []; |
46
|
|
|
|
|
|
|
|
47
|
2
|
|
|
|
|
8
|
foreach my $event (@$events) { |
48
|
16
|
50
|
|
|
|
43
|
if ( defined $event ) { |
49
|
16
|
|
|
|
|
31
|
my $record = _translate($event); |
50
|
16
|
50
|
|
|
|
59
|
push @$raw_lines, $record if $record; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
|
|
|
13
|
return $raw_lines; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub clone { |
58
|
1
|
|
|
1
|
1
|
7
|
my $self = shift; |
59
|
1
|
|
|
|
|
3
|
my $nself = { }; |
60
|
1
|
|
|
|
|
2
|
$nself->{$_} = $self->{$_} for keys %{ $self }; |
|
1
|
|
|
|
|
16
|
|
61
|
1
|
|
|
|
|
4
|
$nself->{BUFFER} = [ ]; |
62
|
1
|
|
|
|
|
5
|
return bless $nself, ref $self; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
##### Generate KennySpeak encoding table |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub _generateKenny { |
68
|
1
|
|
|
1
|
|
3
|
my %kenny; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# lower case characters |
71
|
|
|
|
|
|
|
|
72
|
1
|
|
|
|
|
3
|
my ($a, $b, $c) = (0,0,0); |
73
|
1
|
|
|
|
|
6
|
for my $char ("a".."z") { |
74
|
26
|
|
|
|
|
36
|
my $foo = $a.$b.$c; |
75
|
26
|
|
|
|
|
28
|
$foo =~ tr/012/mpf/; |
76
|
26
|
|
|
|
|
62
|
$kenny{$char} = $foo; |
77
|
26
|
|
|
|
|
24
|
$c++; |
78
|
26
|
100
|
|
|
|
56
|
if ($c == 3) { |
79
|
8
|
|
|
|
|
10
|
$c=0; |
80
|
8
|
|
|
|
|
9
|
$b++; |
81
|
8
|
100
|
|
|
|
21
|
if ($b == 3) { |
82
|
2
|
|
|
|
|
3
|
$b=0; |
83
|
2
|
|
|
|
|
4
|
$a++; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# upper case characters |
89
|
|
|
|
|
|
|
|
90
|
1
|
|
|
|
|
169
|
map { $kenny{uc $_} = ucfirst $kenny{$_} } keys %kenny; |
|
26
|
|
|
|
|
82
|
|
91
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
5
|
return \%kenny; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
##### Generate KennySpeak decoding table |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub _generateDeKenny { |
100
|
1
|
|
|
1
|
|
1
|
my %dekenny; |
101
|
1
|
|
|
|
|
3
|
my $kenny = $_[0]; |
102
|
1
|
|
|
|
|
1
|
foreach my $key (keys %{$kenny}) |
|
1
|
|
|
|
|
18
|
|
103
|
|
|
|
|
|
|
{ |
104
|
52
|
|
|
|
|
144
|
my ($a, $b, $c) = split //, $kenny->{$key}; |
105
|
52
|
100
|
|
|
|
123
|
if (! exists $dekenny{$a}) { |
106
|
6
|
|
|
|
|
14
|
$dekenny{$a} = {}; |
107
|
|
|
|
|
|
|
} |
108
|
52
|
100
|
|
|
|
122
|
if (! exists $dekenny{$a}->{$b}) { |
109
|
18
|
|
|
|
|
61
|
$dekenny{$a}->{$b} = {}; |
110
|
|
|
|
|
|
|
} |
111
|
52
|
|
|
|
|
250
|
$dekenny{$a}->{$b}->{$c} = $key; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
1
|
|
|
|
|
7
|
return \%dekenny; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
##### Encode/decode a given line |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub _translate { |
121
|
32
|
|
|
32
|
|
48
|
my $in = shift; |
122
|
32
|
|
|
|
|
41
|
my $dialect = shift; |
123
|
32
|
|
|
|
|
446
|
my $out = ''; |
124
|
32
|
100
|
|
|
|
62
|
if ($dialect) { |
125
|
16
|
100
|
|
|
|
3189
|
$out .= exists $kenny->{$1} ? $kenny->{$1} : $1 while ($in =~ s/^(.)//); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
else { |
128
|
16
|
|
|
|
|
1357
|
my @chars = split //, $in; |
129
|
16
|
|
|
|
|
719
|
while (@chars) { |
130
|
656
|
100
|
100
|
|
|
3555
|
if ((@chars > 2) and (exists $dekenny->{$chars[0]}->{$chars[1]}->{$chars[2]})) { |
131
|
516
|
|
|
|
|
2048
|
$out .= $dekenny->{$chars[0]}->{$chars[1]}->{$chars[2]}; |
132
|
516
|
|
|
|
|
706
|
shift @chars; |
133
|
516
|
|
|
|
|
1598
|
shift @chars; |
134
|
516
|
|
|
|
|
1409
|
shift @chars; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
else { |
137
|
140
|
|
|
|
|
426
|
$out .= shift @chars; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
} |
141
|
32
|
|
|
|
|
80
|
return $out; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
'Fmpmmmpmfpmp pmfmffpmpmpp Pmpmppppppppffm!'; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# |
148
|
|
|
|
|
|
|
# kenny.pl -- translate from and to KennySpeak |
149
|
|
|
|
|
|
|
# |
150
|
|
|
|
|
|
|
# $Revision: 1.7 $ |
151
|
|
|
|
|
|
|
# |
152
|
|
|
|
|
|
|
# Licensed unter the Artistic License: |
153
|
|
|
|
|
|
|
# http://www.perl.com/language/misc/Artistic.html |
154
|
|
|
|
|
|
|
# |
155
|
|
|
|
|
|
|
# (C) 2001,2002 by Christian Garbs , http://www.cgarbs.de |
156
|
|
|
|
|
|
|
# Alan Eldridge |
157
|
|
|
|
|
|
|
# |
158
|
|
|
|
|
|
|
# KennySpeak invented by Kohan Ikin |
159
|
|
|
|
|
|
|
# http://www.namesuppressed.com/kenny/ |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
__END__ |