The code I am running is
#!/usr/bin/perl use warnings; use strict; my $content = qq(Three blind mice. Three blind mice. See how they ru +n. See how they run. The butcher's wife came after them with a knif +e, three blind mice.); my @words = split(/\s+/, $content); my @words_bi; foreach (@words) { print "$_\n\n"; } foreach (0..$#words) { next if $_ < 1; push(@words_bi, [ @words[$_-1 .. $_] ] ); } foreach (@words_bi) { print "$_\n\n"; }
Which is resulting in
C:\Documents and Settings\admin\Desktop>perl words.pl Three blind mice. Three blind mice. See how they run. See how they run. The butcher's wife came after them with a knife, three blind mice. ARRAY(0x225a20) ARRAY(0x1853c64) ARRAY(0x184780c) ARRAY(0x18477dc) ARRAY(0x18477ac) ARRAY(0x184777c) ARRAY(0x18475c0) ARRAY(0x1847590) ARRAY(0x1847560) ARRAY(0x1847530) ARRAY(0x1847500) ARRAY(0x18474d0) ARRAY(0x18474a0) ARRAY(0x1847470) ARRAY(0x1847440) ARRAY(0x1847410) ARRAY(0x18473e0) ARRAY(0x18473b0) ARRAY(0x1847380) ARRAY(0x1847350) ARRAY(0x1847320) ARRAY(0x18472f0) ARRAY(0x18472c0) ARRAY(0x1847290) ARRAY(0x184720c) C:\Documents and Settings\admin\Desktop>
Thanks!

In reply to Re^4: Word density by Anonymous Monk
in thread Word density by Anonymous Monk

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.