in reply to Perl and Context Free Grammar
You may want to have a look at Parse::RandGen. Not used it myself so can't comment on it's reliability etc but from the documentation it looks ideal for your purpose.
In Section
Seekers of Perl Wisdom
in reply to Perl and Context Free Grammar