]>
iEval git - filters.git/blob - kenny
3 # kenny.pl -- translate from and to KennySpeak
7 # Licensed unter the Artistic License:
8 # http://www.perl.com/language/misc/Artistic.html
10 # (C) 2001,2002 by Christian Garbs <mitch@cgarbs.de>, http://www.cgarbs.de
11 # Alan Eldridge <alane@geeksrus.net>
13 # KennySpeak invented by Kohan Ikin <syneryder@namesuppressed.com>
14 # http://www.namesuppressed.com/kenny/
17 # $Id: kenny.pl,v 1.7 2002/01/06 22:09:52 mitch Exp $
23 # This is Perl POD documentation.
24 # You can generate a nice manpage with "pod2man kenny.pl > kenny.man".
25 # Or have a look at "perldoc perlpod" for other options
30 kenny.pl -- translate from and to KennySpeak
38 S<[ I<file1> ] [ I<file2> ] ...>
42 kenny.pl translates a given text from or to B<KennySpeak>. KennySpeak
45 "Ppfmfp ppmffm mfmppfmpm, fmpmfpmppffm'fpmmpp
46 pmpmffpmfpmfmppmpm Pmpmppppppppffm!"
50 kenny.pl will read the given filenames, translate them and print the
51 results on stdout. If you don't give a filename, stdin is used. A F<->
52 as a filename means stdin.
54 Without any parameters, kenny.pl will look at the first line of input
55 and guess which way you want to translate. If kenny.pl guesses wrong,
56 you must select the translation mode using the B<-k> or B<-d> switch.
64 This will print a short notice and a quick summary of the available
69 This will convert German umlauts to Ae, Oe, Ue, ae, oe, ue and ss
70 so that they can be kennyfied correctly.
74 Kennyfy. This forces the input to be translated into KennySpeak.
78 Dekennyfy. This forces the input to be translated back from
85 This is $Revision: 1.7 $.
89 The B<-u> switch might not work for charsets other than Latin-1. You
90 might try to convert the kenny.pl script using B<recode> to change it
91 from Latin-1 to your preferred charset.
95 kenny.pl was written by B<Christian Garbs>. Look on his homepage for
96 newer versions of kenny.pl. Bug reports or comments about the program
97 should be sent to him:
98 Christian Garbs <F<mitch@cgarbs.de>>
99 F<http://www.cgarbs.de/weird.en.html>
101 KennySpeak was invented by B<Kohan Ikin>. See his homepage for an
102 online version of the original B<KennyTranslator>:
103 Kohan Ikin <F<syneryder@namesuppressed.com>>
104 F<http://www.namesuppressed.com/kenny/>
106 Alan Eldridge <F<alane@geeksrus.net>> patched in a signal handler to
107 print an appropriate message when kenny.pl is killed.
111 kenny.pl is licensed unter the B<Artistic License> which can be found
112 at F<http://www.perl.com/language/misc/Artistic.html>. This license
113 has been chosen for keeping compatibility with the original KennySpeak
120 ######################################################################
125 # Revision 1.7 2002/01/06 22:09:52 mitch
126 # Included patch by Alan Eldridge <alane@geeksrus.net>
127 # to show a message when kenny.pl is killed.
129 # Revision 1.6 2001/07/20 19:04:49 mitch
130 # Removed warnings with Perl 5.6.
131 # Thanks go to Alan Eldridge <alane@geeksrus.net>
133 # Revision 1.5 2001/07/15 10:27:57 mitch
134 # Included notice about -u and charsets other than Latin-1.
136 # Revision 1.4 2001/07/14 13:16:30 mitch
141 ######################################################################
146 # finally{}, the source code!
151 ##### Declaration of function prototypes
154 sub generateDeKenny
($);
157 sub addGermanUmlauts
($);
159 sub theyKilledKenny
();
163 ##### Default values for various option:
165 my $dialect = 0; # Translate from or to KennySpeak?
166 # 0=guess, 1=encode, 2=decode
168 my $umlauts = 0; # Convert German Umlauts before translation?
169 # TRUE=ÄÖÜäöüß => Ae, Oe, Ue, ae, ou, ue, ss
173 ##### The KennySpeak translation tables:
175 my $kenny = generateKenny
(); # encoding table
176 my $dekenny = generateDeKenny
($kenny); # decoding table
180 ##### Install signal handlers
182 $SIG{HUP
} = \
&theyKilledKenny
;
183 $SIG{INT
} = \
&theyKilledKenny
;
184 $SIG{QUIT
} = \
&theyKilledKenny
;
185 $SIG{TERM
} = \
&theyKilledKenny
;
189 ##### Parse commandline arguments
191 # "-h" switch (print help):
193 if (grep /^-h$/, @ARGV) {
198 # "-u" switch (convert German umlauts):
200 if ((defined $ARGV[0]) && ($ARGV[0] eq "-u")) {
203 } elsif ((defined $ARGV[1]) && ($ARGV[1] eq "-u")) {
208 # "-k" and "-d" switch (force encoding/decoding):
210 if (defined $ARGV[0]) {
211 if ($ARGV[0] eq "-k") {
214 } elsif ($ARGV[0] eq "-d") {
222 ##### add German umlauts to encoding if desired:
225 addGermanUmlauts
($kenny);
230 ##### Process the given input files (or stdin of none given)
232 while (my $line=<>) {
234 $dialect = guessDialect
($line) unless $dialect;
235 $line = translate
($line);
241 ##### That's all, folks!
246 ##### Signal handler, if we're kill(1)ed
248 sub theyKilledKenny
()
250 print "Oh my God! They killed Kenny! You bastards!\n";
256 ##### Guess whether input is already kennyfied:
261 $line =~ tr/a-zA-Z//cd;
262 if (($line =~ tr/mfpMFP//c) > 0) {
271 ##### Encode/decode a given line
279 $out .= exists $kenny->{$1} ?
$kenny->{$1} : $1 while ($in =~ s/^(.)//);
281 my @chars = split //, $in;
283 if ((@chars > 2) and (exists $dekenny->{$chars[0]}->{$chars[1]}->{$chars[2]})) {
284 $out .= $dekenny->{$chars[0]}->{$chars[1]}->{$chars[2]};
289 $out .= shift @chars;
298 ##### Generate KennySpeak encoding table
304 # lower case characters
306 my ($a, $b, $c) = (0,0,0);
307 for my $char ("a".."z") {
310 $kenny{$char} = $foo;
322 # upper case characters
324 map { $kenny{uc $_} = ucfirst $kenny{$_} } keys %kenny;
331 ##### Generate KennySpeak decoding table
333 sub generateDeKenny
($)
337 foreach my $key (keys %{$kenny})
339 my ($a, $b, $c) = split //, $kenny->{$key};
340 if (! exists $dekenny{$a}) {
343 if (! exists $dekenny{$a}->{$b}) {
344 $dekenny{$a}->{$b} = {};
346 $dekenny{$a}->{$b}->{$c} = $key;
354 ##### Add German Umlaut conversion to KennySpeak encoding table
356 sub addGermanUmlauts
($)
359 $kenny->{"ä"} = $kenny->{"a"} . $kenny->{"e"};
360 $kenny->{"ö"} = $kenny->{"o"} . $kenny->{"e"};
361 $kenny->{"ü"} = $kenny->{"u"} . $kenny->{"e"};
362 $kenny->{"Ä"} = $kenny->{"A"} . $kenny->{"e"};
363 $kenny->{"Ö"} = $kenny->{"O"} . $kenny->{"e"};
364 $kenny->{"Ü"} = $kenny->{"U"} . $kenny->{"e"};
365 $kenny->{"ß"} = $kenny->{"s"} x
2;
370 ##### Print short help message
375 kenny.pl $Revision: 1.7 $ by Christian Garbs <mitch@cgarbs.de>
376 Use "pod2man kenny.pl > kenny.man" to generate the man page.
377 Usage: kenny.pl [ -h ] [ -u ] [ -k | -d ] [ file1 ] [ file2 ] ...
378 -h : print this help message
379 -u : convert German umlauts before translation
380 -k : force encoding to KennySpeak
381 -d : force decoding from KennySpeak
This page took 0.082729 seconds and 4 git commands to generate.