When this is run, you'd see something that looks like this, plus or minus input and random factors:When I was walking down the [street|boulevard|avenue] a large [squirrel|frog|lemur|llama] [leaped|jumped|ran|crawled] out and [bit|mauled|chewed|spit at] me! You'd never believe what [Name?] said!
If you're probably thinking this is a couple of simple regexes, you're not entirely wrong. However, to spice things up, there's a few "rules" about how the program runs:% perl madlib sample.madlib Name? George Jetson When I was walking down the avenue a large llama jumped out and bit me! You'd never believe what George Jetson said!
select STDERR;$|++;select STDOUT;$_=join('',<>); s#\[([^\]]*\?)\]#print STDERR"$1 ";chomp($i=<STDIN>);$i#ge; s#\[([^\]]*)\]#@f=split(/\|/,$1);$f[rand@f]#ge;print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (Golf) Mad-Lib Generator
by abstracts (Hermit) on Jul 17, 2002 at 03:59 UTC | |
|
Re: (Golf) Mad-Lib Generator
by japhy (Canon) on Jul 17, 2002 at 16:21 UTC | |
|
Re: (Golf) Mad-Lib Generator
by Util (Priest) on Jul 17, 2002 at 16:07 UTC | |
|
Re: (Golf) Mad-Lib Generator
by vladb (Vicar) on Jul 17, 2002 at 04:14 UTC | |
by japhy (Canon) on Jul 17, 2002 at 18:43 UTC | |
|
Re: (Golf) Mad-Lib Generator
by japhy (Canon) on Jul 17, 2002 at 15:44 UTC | |
|
•Re: (Golf) Mad-Lib Generator
by merlyn (Sage) on Jul 17, 2002 at 21:40 UTC | |
|
Re: (Golf) Mad-Lib Generator
by MrCromeDome (Deacon) on Jul 17, 2002 at 13:15 UTC |