#! perl -slw use strict; while( ) { 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