Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Random nonsense generator

by Anonymous Monk
on Nov 09, 2003 at 14:55 UTC ( #305678=CUFP: print w/replies, xml ) Need Help??

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

Replies are listed 'Best First'.
•Re: Random nonsense generator
by merlyn (Sage) on Nov 09, 2003 at 16:07 UTC
Re: Random nonsense generator
by pg (Canon) on Nov 09, 2003 at 18:31 UTC

    What if you modify your program a bit and get something like one of those online dictionaries involved?

    You will still get random sentences that make no sense (most of the time), but with words that recognizable. Once a while you may get some good laughter ;-P.

Re: Random nonsense generator
by belg4mit (Prior) on Nov 10, 2003 at 05:17 UTC
    You might find lc in combination with travesty enlightening prior art.

    I'm not belgian but I play one on TV.

      You might also find nonsense to be prior art. Fun stuff!

      I used it for a few projects and it's very versatile.

      - Mark Beihoffer, Network Architect

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://305678]
Approved by gmax
and God said, "Let Newton be!"...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2017-05-23 17:24 GMT
Find Nodes?
    Voting Booth?