]>
Commit | Line | Data |
---|---|---|
e60f6df6 | 1 | #!/usr/bin/perl |
2 | ||
3 | $row = "!qwertyuiop!asdfghjkl!zxcvbnm!"; | |
4 | @row_array = split(//, $row); | |
5 | ||
6 | while (<>) { | |
7 | chomp; | |
8 | y/A-Z/a-z/; | |
9 | s/\byou\b/u/gi; | |
10 | s/\bpeople\b/ppl/gi; | |
11 | s/\bthrough\b/thru/gi; | |
12 | s/\bthough\b/tho/gi; | |
13 | s/\bnope\b/nup/gi; | |
14 | s/\baustralia\b/oz/gi; | |
bc19f2cf | 15 | s/\bfilm\b/flim/gi; |
e60f6df6 | 16 | s/\bsucks\b/sux/gi; |
17 | s/\benough\b/enuff/gi; | |
18 | s/\ba lot\b/a shitload/gi; | |
19 | s/\bstuff\b/shit/gi; | |
20 | s/, /.. /g; | |
21 | s/\.$/.../g; | |
22 | ||
23 | @lets = split(//); | |
24 | ||
25 | $strlen = $#lets; | |
26 | ||
27 | for ($x = 0; $x < $strlen; $x++) { | |
28 | if (rand() < 0.01) { | |
29 | swap(\@lets, $x, $x + 1); | |
30 | next; | |
31 | } | |
32 | ||
33 | if (rand() < 0.10 && $lets[$x] eq " ") { | |
34 | swap(\@lets, $x - 1, $x - 2); | |
35 | next; | |
36 | } | |
37 | ||
38 | if(rand() < 0.01) { | |
39 | $i = insert_adjacent(\@lets, $x, $lets[$x]); | |
40 | $strlen += $i; | |
41 | next; | |
42 | } | |
43 | ||
44 | if(rand() < 0.01) { | |
45 | splice(@lets, $x, 1); | |
46 | $strlen--; | |
47 | next; | |
48 | } | |
49 | } | |
50 | ||
51 | print join("", @lets) . "\n"; | |
52 | } | |
53 | ||
54 | sub insert_adjacent { | |
55 | my($aref, $pos, $let) = @_; | |
56 | ||
57 | ||
58 | $newlet = get_adjacent($let); | |
59 | ||
60 | if( !$newlet ) { | |
61 | return 0; | |
62 | } | |
63 | ||
64 | splice(@$aref, $pos + 1, 0, $newlet); | |
65 | return 1; | |
66 | } | |
67 | ||
68 | ||
69 | sub get_adjacent { | |
70 | my($let) = @_; | |
71 | ||
72 | return 0 if $let !~ /[a-zA-Z]/; | |
73 | ||
74 | $i = index($row, $let); | |
75 | $before = $row_array[$i - 1]; | |
76 | $after = $row_array[$i + 1]; | |
77 | ||
78 | ||
79 | ||
80 | if( $before eq "!" || (rand() < rand() && $after ne "!")) { | |
81 | return $after; | |
82 | } else { | |
83 | return $before; | |
84 | } | |
85 | } | |
86 | ||
87 | sub swap { | |
88 | my($aref, $n, $m) = @_; | |
89 | my($tmp); | |
90 | ||
91 | if(defined($$aref[$n]) && defined($$aref[$m])) { | |
92 | if(! (($$aref[$n] =~ /[A-Z ]/ && $$aref[$m] =~ /[A-Z ]/) || | |
93 | ($$aref[$n] =~ /[a-z ]/ && $$aref[$m] =~ /[a-z ]/) )) { | |
94 | return; | |
95 | } | |
96 | $tmp = $$aref[$n]; | |
97 | $$aref[$n] = $$aref[$m]; | |
98 | $$aref[$m] = $tmp; | |
99 | } | |
100 | } | |
101 |