This is a fun and interesting text analysis project. On a side note, for those who want to expiriment with this type of project straight from perl, the functionality can also be implemented relatively well with array references and a function that chooses random elements therefrom.

This is an alternative route for those who are unable to install a module like yours or Inline::Spew.

### INIT script use strict; use warnings; use SpewUtils qw(Rc1 RcN RoD ScrubST) ; ### script for my $item (0..5){ print GenSaying000(); print ("\n-----------------------------------\n"); } sub GenSaying000 { my $strOut = Sentence(); $strOut = ScrubST($strOut); return $strOut; }###end_sub sub Sentence { Rc1([qw( The A )])." @{[adjective()]} @{[animal()]} sat on the + @{[object()]} @{[adjacency()]}"; }###end_sub sub animal { Rc1([qw( cat dog rat mouse cheetah elephant )]) }###end_sub sub object { Rc1([qw( fence mat shovel car roof )]) ; }###end_sub sub adjacency { Rc1([ 'near', 'behind', 'next to', 'underneath', ]) ." the " .Rc1([ 'doorway', 'outhouse', 'patio', 'fence', 'corner', 'b +order' ]) ; }###end_sub sub adjective{(0)?"" :(RoD(6) > 5)? 'fluffy' :(RoD(6) > 5)? 'furry' :(RoD(6) > 5)? 'lazy' :(RoD(6) > 1)? 'very ' . "@{[adjective()]}" :(1)? @{RcN([qw(shiny happy clammy yummy silly happy jolly)], +rand(4))} :'' } 1; __END__

In reply to Re: generator_generator: generate a C++ string generator from a grammar by dimar
in thread generator_generator: generate a C++ string generator from a grammar by coppit

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.