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 ;)


In reply to Random nonsense generator by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.