use strict; use warnings; use Data::Dumper; my $debug = 0; my %data = ( ); my $sentence; sub read_it { my ($in_section, $section_name, $buff); while () { chomp; #kill cr/lf $_ = join ( ' ', split(' ')); # will strip leading, trailing, and internal spaces next unless $_; # skip blank lines print "RAW DATA: [$_]\n" if $debug; if ($_ eq '{') { print "\tEntering new block section..\n" if $debug; $in_section =1; next; } if ($_ eq '}') { print "\tLeaving section: [$section_name]\n" if $debug; $in_section = 0; $section_name = ''; $buff = ''; next; } unless ($in_section){ # skip comments and other junk outside blocks print "\tNot in block section... Skipping.\n" if $debug; next; } ## In data section if ($section_name) { if (s/\s*;$//) { if ($buff) { $buff .= " $_"; push @{$data{$section_name}}, $buff; print "\tRead whole statement. Adding to data structure. [$buff]\n" if $debug; }else{ push @{$data{$section_name}}, $_; print "\tRead whole statement. Adding to data structure. [$_]\n" if $debug; } next; }else{ print "\tAdding [$_] to buffer.\n" if $debug; if ($buff) { $buff .= " $_"; }else { $buff = $_; } next } }else{ ## check for section name...
if ( /<(.+?)>/) { $section_name = $1; # set section name print "\tSetting section name to: [$section_name]\n" if $debug; next; }else{ ## must have been comment print "\tNot setting section name.. Must have been comment.\n" if $debug; next; } } } } sub _parse_it { my $d = shift; my ($front,$middle, $back); ## if nothing to expand then just print it (print $d) && return unless ( $d =~ /(.*?)<(.+?)>(.*)/ ); ## else if there is something before expansion print it $front = $1; $middle = $2; $back = $3; print $front; $middle = $data{$middle}->[ rand @{$data{$middle}} ]; $middle = $middle . $back; _parse_it($middle); } sub write_it { _parse_it($sentence); } read_it; print Dumper (%data) if $debug; $sentence = $data{start}->[ rand @{$data{start}}]; print "GRAMMAR: $sentence.\n\n"; write_it; __DATA__ Insult grammar by Micah Jaffe (zeade@cyclone.stanford.edu) It creates three basic types with even more sub-types, etc etc. Hehe. Some of the adjectives and 's were taken from the Macintosh hypercard stack "Random Insults." The curses are all "original" ;) ------------------------------------------------------ { You . ; May . ; } Some others you may want to include, but I like the other two better: You are so that even a would not want to you . ; With the of , may . ; adj1 deals more with um degrading things about the person abilities, adj2 more about appearance (used when refering to the mutant beasties) { ; ; , ; } { ; ; } { lame ; dried up ; par-broiled ; bloated ; half-baked ; spiteful ; egotistical ; ungrateful ; stupid ; moronic ; fat ; ugly ; puny ; pitiful ; insignificant ; blithering ; repulsive ; worthless ; blundering ; retarded ; useless ; obnoxious ; low-budget ; assinine ; neurotic ; subhuman ; crochety ; indescribable ; contemptible ; unspeakable ; sick ; lazy ; good-for-nothing ; slutty ; mentally-deficient ; creepy ; sloppy ; dismal ; pompous ; pathetic ; friendless ; revolting ; slovenly ; cantankerous ; uncultured ; insufferable ; gross ; unkempt ; defective ; crumby ; } { putrefied ; festering ; funky ; moldy ; leprous ; curdled ; fetid ; slimy ; crusty ; sweaty ; damp ; deranged ; smelly ; stenchy ; malignant ; noxious ; grimy ; reeky ; nasty ; mutilated ; sloppy ; gruesome ; grisly ; sloshy ; wormy ; mealy ; spoiled ; contaminated ; rancid ; musty ; fly-covered ; moth-eaten ; decaying ; decomposed ; freeze-dried ; defective ; petrified ; rotting ; scabrous ; hirsute ; } { ; , bad excuse for ; , for brains ; , for brains ; offspring of a motherless ; ; ; } { shit ; toe jam ; filth ; puss ; earwax ; leaf clippings ; bat guano ; mucus ; fungus ; mung ; refuse ; earwax ; spittoon spittle ; phlegm ; } { bit of ; piece of ; vat of ; lump of ; crock of ; ball of ; tub of ; load of ; bucket of ; mound of ; glob of ; bag of ; heap of ; mountain of ; load of ; barrel of ; sack of ; blob of ; pile of ; truckload of ; vat of ; } { droppings ; mung ; zits ; puckies ; tumors ; cysts ; tumors ; livers ; froth ; parts ; scabs ; guts ; entrails ; blubber ; carcuses ; gizards ; ; } { kidneys ; genitals ; buttocks ; earlobes ; innards ; feet ; } { pop tart ; warthog ; twinkie ; barnacle ; fondue pot ; cretin ; fuckwad ; moron ; ass ; neanderthal ; nincompoop ; simpleton ; ; } { donkey ; llama ; dingo ; lizard ; gekko ; lemur ; moose ; camel ; goat ; eel ; } { love ; cuddle ; fondle ; adore ; smooch ; hug ; caress ; worship ; } The curses... { ; ; find your suddenly delectable ; and seek a battleground ; } { ; ; ; ; a Rush Limbaugh ; the hosts of Hades ; } { a hoard of ; a pack of ; a truckload of ; a swarm of ; many ; an army of ; a heard of ; a platoon of ; a and group of ; ; } { a thousand ; three million ; ninty-nine ; nine-hundred, ninty-nine ; forty-two ; a gazillion ; sixty-eight times thirty-three ; } { viciously ; manicly ; merrily ; happily ; , with the of , ; gleefully ; , with much ritualistic celebration , ; franticly ; } { an irate manticore ; Thor's belch ; Alah's fist ; titans ; a particularly vicious she-bear in the midst of her menstrual cycle ; a pissed-off Jabberwock ; } { force ; fury ; power ; rage ; } { spit ; shimmy ; slobber ; find refuge ; find shelter ; dance ; retch ; vomit ; defecate ; erect a strip mall ; build a ; have a religious experience ; discharge bodily waste ; fart ; dance ; drool ; lambada ; spill rusty tacks ; bite you ; sneeze ; sing campfire songs ; smite you times ; construct a new home ; throw a party ; procreate ; } { yaks ; maggots ; cockroaches ; stinging scorpions ; fleas ; weasels ; gnats ; South American killer bees ; spiders ; monkeys ; wiener-dogs ; rats ; wolverines ; , pit-fiends ; } { frothing ; manic ; crazed ; plague-ridden ; disease-carrying ; biting ; rabid ; blood-thirsty ; ravaging ; slavering ; } { in ; upon your mother's grave ; on best rug ; in the you call home ; upon your heinie ; } { your ; your ; your ; your father's ; your mother's ; your grandma's ; } { entrails ; anal cavity ; shoes ; house ; pantry ; general direction ; pants ; bed ; } { rat hole ; sewer ; toxic dump ; oil refinery ; landfill ; porto-pottie ; } -- Micah Jaffe zeade@cyclone.stanford.edu DCC Consultant (415) 424-9532 "Crbcyr ner yvxr n obk bs pubpbyngrf. Lhz." -- Sbeerfg Qnuyzre