Philmac has asked for the wisdom of the Perl Monks concerning the following question:

I was looking for a Markov chain based text generator that I need for work/school and I came across a thread on this forum that made reference to this perl program: http://cm.bell-labs.com/cm/cs/tpop/markov.pl However, I cannot figure out how to make it work. So far every time I run it all it does it regurgitate the input file. What am I doing wrong?

Replies are listed 'Best First'.
Re: How do I use this Markov generator?
by duff (Parson) on Apr 19, 2007 at 23:36 UTC

    You're not providing enough context for us to determine what you are doing wrong. Are you sure it's regurgitating the input file and not a markov-morphed version of it? What does the file that you are providing for input look like? IIRC, it should be a file of normal english language text.

      I see what I was doing wrong. I was using a word list as input before.
Re: How do I use this Markov generator?
by polettix (Vicar) on Apr 20, 2007 at 01:28 UTC
    Just put the following:
    this is an interesting text because this is what could be a more interesting text for us
    into filename and call:
    perl markov.pl filename
    two or three times, comparing results. If you have bash, you can also do this:
    perl markov.pl <<<'this is an interesting text because this is what could be a more interesting text for us'
    Update: fixed stray sentence.

    Flavio
    perl -ple'$_=reverse' <<<ti.xittelop@oivalf

    Don't fool yourself.
      Thanks, I got it working now. Although, this program generates text based on words. How difficult would it be to make it generate text based on characters?
        Same level of difficulty