http://www.perlmonks.org?node_id=59980


in reply to Sentence format

Assuming you keep your articles/verbs/nouns in different files, this wouldn't be terribly difficult:
my(@sentenceformats) = ( 'a v n', 'a v n v n' ); #pick a sentence format -- there's probably a much #easier way to do this! my($sent) = int(rand($#sentenceformats))); my(@format) = split(/ /, $sentenceformat[$sent]); for (@format) { if (/a/) { #pick a article } elsif (/v/) { #pick a verb } elsif (/n/) { #pick a noun } else { warn "Unknown sentence fragment\n"; }; };

Of course, this is all untested, and I /think/ it should work.. YMMV.

-marius