Just a little something to waste (a little) cpu time with :)
It generates random sentences with nonsense words like:
A trebble pangs lall.
All the words are in a separate file, with shebangs standing for random vowels. The code should be self-explanatory.
#!/usr/bin/perl
#babble
@articles = ("a ", "the ", "");
@punctuation = (".", "!", "?");
open WORDFILE, ".babblewords"; #read words from file
chop(@words = <WORDFILE>); #and get rid of \n
@vowels = ("a", "e", "i", "o", "u");
$frase = "S V O"; #Subject, Verb and Object
for ($frase) {
#replace S, O and V with words and add punctuation
s/S/$articles[int(rand($#articles + 1))]$words[int(rand($#words + 1))]
+/g;
s/O/$articles[int(rand($#articles + 1))]$words[int(rand($#words + 1))]
+/g;
s/V/$words[int(rand($#words + 1))]s/g;
$_ .= $punctuation[int(rand $#punctuation + 1)];
#calculate number of shebangs in text and replace with random vowe
+ls
$number = tr/#/#/;
$a = 0;
eval "s/#/$vowels[int(rand($#vowels + 1))]/;" until $a++ == $number;
}
print STDOUT ucfirst $frase, "\n";
Here's the current .babblewords file: (I'm thinking of implementing a random word generator too)
tr#bble
j#ng
y#t
f#t
f#ng
p#ng
l#ll
sh#ng
b#th
b#the
b#ll
c#rr
gl#pe
gl#t
t#rb
gr#t
gr#l
k#st
wr#t
j#te
h#the
Have fun, and add this into your .login file ;)