in reply to (Golf) Mad-Lib Generator
select *I=*STDERR;$|++;select STDOUT;$_=join('',<DATA>); s#\[([^\]]*\?)\]#print I"$1 ";chomp($i=<DATA>);$i#ge; s#\[([^\]]*)\]#@f=split(/\|/,$1);$f[rand@f]#ge;print
print map{s/\?$/? /?print(STDERR)&&(<>=~/.*/g)[0]:split('\|')&&$_[rand +@_]} map{split/\[(.+?)\]/}<>
Source file:#!/usr/local/bin/perl print map{s/\?$/? /?print(STDERR)&&(<>=~/.*/g)[0]:split('\|')&&$_[rand +@_]} map{split/\[(.+?)\]/}<>
Hmm,.. but it does appear to print extra '0's when I use the original text. Let me investigate why that's the case ... update: This works:Hello [world|planet|dude|there], [Name?]!
print map{if(s/\?$/? /){print STDERR;(<>=~/.*/g)[0]}@z=split/\|/;$z[ra +nd@z]} map{split/\[(.+?)\]/}<>
# Under Construction
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: (Golf) Mad-Lib Generator
by japhy (Canon) on Jul 17, 2002 at 18:43 UTC |