#!/usr/bin/perl use warnings; use strict; my $content = qq(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.); 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"; }