#!/usr/bin/perl #babble @articles = ("a ", "the ", ""); @punctuation = (".", "!", "?"); open WORDFILE, ".babblewords"; #read words from file chop(@words = ); #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 vowels $number = tr/#/#/; $a = 0; eval "s/#/$vowels[int(rand($#vowels + 1))]/;" until $a++ == $number; } print STDOUT ucfirst $frase, "\n";