I happen to have access to an old freebsd machine that still runs 5.8.8 (hasn't been updated in ages...) and I see that the output looks like stuff that you've shown in earlier posts on this same general topic:
It is a t is a is a guide s a guide a guide to guide to action uide to action ide to action de to action e to action to action which o action which action which ensures ction which ensures tion which ensures ion which ensures on which ensures n which ensures which ensures that hich ensures that ich ensures that ch ensures that h ensures that ensures that the nsures that the sures that the ures that the res that the es that the s that the that the military hat the military at the military t the military the military always he military always e military always military always obey ilitary always obey litary always obey itary always obey tary always obey ary always obey ry always obey y always obey always obey the lways obey the ways obey the ays obey the ys obey the s obey the obey the commands bey the commands ey the commands y the commands the commands of he commands of e commands of commands of the ommands of the mmands of the mands of the ands of the nds of the ds of the s of the of the party. f the party.

Well, because I first learned about the (?=...) regex construct (referred to as a "positive look-ahead assertion") when using 5.8.8, I have to assume there's something tricky and unexpected that happens when the look-ahead expression can match variable-length strings (and this was apparently fixed in 5.10).

If you really have to construct word trigrams in 5.8.8, I guess you'll have to do something other than a pure regex solution relying that sort of syntax. The easier way to do word n-grams is to use split:

my $str1 = q/It is a guide to action which ensures that the military a +lways obey the commands of the party./; my $str2 = q/It is a guide to action that ensures that the military wi +ll forever heed Party commands is a guide./; for my $str ( $str1, $str2 ) { print "=== input is [$str] ===\n"; my @words = split / /, $str; while ( @words >= 3 ) { print join( " ", @words[0..2] ), "\n"; shift @words; } print "\n"; }
Of course, if that doesn't satisfy the contrived conditions of a given homework assignment ("You must not use 'split'! And you must use Perl 5.8.8!!"), well, that's a shame. The instructor ought to know better (or shouldn't be so deliberately mean to the poor students...)

In reply to Re: output differs in perl version by graff
in thread output differs in perl version by sarvan

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.