#!/usr/bin/perl -w $/=" "; while(<>) { while($_=~m/\b(\w+\b)(\s+\1)\b/xig) { print "dup words '$1' occurs at paragraph $.\n"; } }