dbk: Delete comments with function name at end of functions
[sunny256-utils.git] / l33t
blob238eff2c74bc7b4aca76f8fdcfd27c71106e3ee1
1 #!/usr/bin/env perl
3 # l33t - auto l33t converter. Perl, Unix.
5 # This program converts text to l33t-speak. This is helpful to convert text
6 # that has been written in a formal and confusing manner, into text that
7 # is easy to follow.
9 # 16-Jun-2005 ver 0.80
11 # USAGE: l33t [-abnuv] textfile
13 # l33t -a # all
14 # l33t -b # basic-l33t
15 # l33t -n # normal-l33t (default)
16 # l33t -u # ultra-l33t
17 # l33t -v # verbose
18 # eg,
19 # l33t message.txt
20 # man ls | l33t | more
22 # SEE ALSO: gwhiz(1)
24 # THANKS: Boyd Adamson
26 # COPYRIGHT: Copyright (c) 2005 Brendan Gregg.
28 # This program is free software; you can redistribute it and/or
29 # modify it under the terms of the GNU General Public License
30 # as published by the Free Software Foundation; either version 2
31 # of the License, or (at your option) any later version.
33 # This program is distributed in the hope that it will be useful,
34 # but WITHOUT ANY WARRANTY; without even the implied warranty of
35 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 # GNU General Public License for more details.
38 # You should have received a copy of the GNU General Public License
39 # along with this program; if not, write to the Free Software Foundation,
40 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
42 # (http://www.gnu.org/copyleft/gpl.html)
44 # 16-Jun-2005 Brendan Gregg Created this.
46 use Getopt::Std;
47 $| = 1;
50 # Command Line Arguments
52 &usage() if $ARGV[0] eq "--help";
53 getopts('abnuv') || &usage();
54 &usage() if $opt_h;
55 $BASIC = 1 if $opt_b || $opt_a || $opt_u || $opt_n;
56 $NORMAL = 1 if $opt_n || $opt_a || $opt_u;
57 $ULTRA = 1 if $opt_u || $opt_a;
58 $VERBOSE = 1 if $opt_v || $opt_a;
59 if (($BASIC + $NORMAL + $ULTRA) == 0) {
60 $BASIC = 1;
61 $NORMAL = 1;
63 @Superlatives = ("w00t!","haxx0r","l33t!","d00d");
66 # l33t Data
68 while ($line = <>) {
69 chomp($line);
70 l33t($line);
71 print "$line\n";
75 #################
76 # Subroutines
79 # l33t - l33t the input variable.
80 # This function will write to the input variable,
81 # similar to chomp.
83 sub l33t {
84 $line = shift; # not my
85 my ($char,$new);
86 $new = "";
88 basic_l33t($line) if $BASIC;
89 normal_l33t($line) if $NORMAL;
90 ultra_l33t($line) if $ULTRA;
92 if ($VERBOSE) {
93 if ( int(rand(3)) == 0) {
94 $index = int(rand(@Superlatives));
95 $line .= " $Superlatives[$index]";
100 # basic_l33t - convert the argument string to basic l33t speak.
101 # this code is order dependant.
103 sub basic_l33t {
104 $line = shift; # not my
105 my ($char, $new);
107 ### word conversions
108 $line =~ s/\byou\b/int(rand(2))==0?"u":"you"/ieg;
109 $line =~ s/\bare\b/int(rand(2))==0?"r":"are"/ieg;
111 ### combo conversions
112 $line =~ s/s\b/int(rand(5))!=0?"z":"s"/eg;
113 $line =~ s/\bf/int(rand(2))==0?"ph":"f"/ieg;
115 foreach $char (split(//,$line)) {
117 ### character conversions
118 if ($char eq "a" && int(rand(4)) == 0) { $char = "4"; }
119 if ($char eq "e" && int(rand(3)) == 0) { $char = "3"; }
120 if ($char eq "l" && int(rand(3)) == 0) { $char = "1"; }
121 if ($char eq "o" && int(rand(3)) == 0) { $char = "0"; }
122 if ($char eq "s" && int(rand(4)) == 0) { $char = '5'; }
124 $new .= $char;
126 $line = $new;
128 ### exclimation marks
129 if ($line !~ /^\s*$/) {
130 $line .= "!" x int(rand(3));
134 # normal_l33t - convert the argument string to normal l33t speak.
135 # this code is order dependant.
137 sub normal_l33t {
138 $line = shift; # not my
139 my ($char, $new);
141 ### word conversions
142 $line =~ s/\broot\b/w00t/ig;
143 $line =~ s/\bfiles?\b/int(rand(2))==0?"warez":"files"/ieg;
145 ### combo conversions
146 $line =~ s/cks\b/int(rand(2))==0?"x":"cks"/eg;
147 $line =~ s/er\b/int(rand(2))==0?"or":"er"/eg;
149 foreach $char (split(//,$line)) {
150 $char = lc($char);
152 ### character conversions
153 if ($char eq "a" && int(rand(4)) == 0) { $char = "@"; }
154 if ($char eq "s" && int(rand(4)) == 0) { $char = '$'; }
155 if ($char eq "s" && int(rand(6)) == 0) { $char = "z"; }
156 if ($char eq "t" && int(rand(4)) == 0) { $char = "7"; }
157 if (int(rand(3)) == 0) { $char = uc($char); }
159 $new .= $char;
161 $line = $new;
163 ### exclimation marks
164 if ($line !~ /^\s*$/) {
165 $line .= "!";
166 $line .= "!" x int(rand(3));
167 if (int(rand(6)) == 0) {
168 $line .= "!" x int(rand(3));
169 $line .= "1" x int(rand(3));
170 if (int(rand(8)) == 0) {
171 $line .= "!!1ONE!";
177 # ultra_l33t - convert the argument string to normal l33t speak.
178 # this code is order dependant.
180 sub ultra_l33t {
181 $line = shift; # not my
182 my ($char, $new);
184 ### word conversions
185 $line =~ s/\broot\b/w00t/ig;
187 ### combo conversions
188 $line =~ s/\bf/int(rand(2))==0?"ph":"f"/eg;
190 foreach $char (split(//,$line)) {
191 $char = lc($char);
193 ### character conversions
194 if ($char eq "b" && int(rand(4)) == 0) { $char = "8"; }
195 if ($char eq "c" && int(rand(6)) == 0) { $char = "("; }
196 if ($char eq "d" && int(rand(6)) == 0) { $char = "|)"; }
197 if ($char eq "h" && int(rand(8)) == 0) { $char = "|-|"; }
198 if ($char eq "i" && int(rand(4)) == 0) { $char = "1"; }
199 if ($char eq "k" && int(rand(6)) == 0) { $char = "|<"; }
200 if ($char eq "m" && int(rand(8)) == 0) { $char = "/\\/\\"; }
201 if ($char eq "n" && int(rand(8)) == 0) { $char = "|\\|"; }
202 if ($char eq "r" && int(rand(8)) == 0) { $char = "|2"; }
203 if ($char eq "v" && int(rand(8)) == 0) { $char = "\\/"; }
204 if ($char eq "w" && int(rand(8)) == 0) { $char = "\\/\\/"; }
205 if ($char eq "o" && int(rand(6)) == 0) { $char = "()"; }
206 if ($char eq "g" && int(rand(4)) == 0) { $char = "9"; }
207 if ($char eq "t" && int(rand(4)) == 0) { $char = "+"; }
208 if (int(rand(2)) == 0) { $char = uc($char); }
210 $new .= $char;
212 $line = $new;
214 ### exclimation marks
215 if ($line !~ /^\s*$/) {
216 $line .= "!" x int(rand(3));
220 # usage - print a usage and exit.
222 sub usage {
223 print "USAGE: l33t [-abnuv] [filename]\n";
224 print " eg,\n";
225 print " l33t /etc/release\n";
226 print " date | l33t\n\n";
227 print " l33t -a # all\n";
228 print " l33t -b # basic-l33t\n";
229 print " l33t -n # normal-l33t (default)\n";
230 print " l33t -u # ultra-l33t\n";
231 print " l33t -v # verbose\n";
232 exit 1;