#! perl -slw
use strict;
while( <DATA> ) {
my @words = split /[^a-zA-Z']+/;
for ( 0 .. $#words ) {
printf "%s, $., %s %s %s\n",
$words[ $_ ],
$_ ? $words[ $_ -1 ] : '',
$words[ $_ ],
$_ < $#words ? $words[ $_ + 1 ] : ''
;
}
}
__DATA__
little boy blue come blow on your horn
give a little, take a lot
give a lot, take a little
Mary had a little lamb
Don't belittle the little guy
Outputs [14:37:07.78]C:\test>junk4
little, 1, little boy
boy, 1, little boy blue
blue, 1, boy blue come
come, 1, blue come blow
blow, 1, come blow on
on, 1, blow on your
your, 1, on your horn
horn, 1, your horn
give, 2, give a
a, 2, give a little
little, 2, a little take
take, 2, little take a
a, 2, take a lot
lot, 2, a lot
give, 3, give a
a, 3, give a lot
lot, 3, a lot take
take, 3, lot take a
a, 3, take a little
little, 3, a little
Mary, 4, Mary had
had, 4, Mary had a
a, 4, had a little
little, 4, a little lamb
lamb, 4, little lamb
Don't, 5, Don't belittle
belittle, 5, Don't belittle the
the, 5, belittle the little
little, 5, the little guy
guy, 5, little guy
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|