
use strict 'vars';
undef $/;
my $file = <>;

while ($file =~ /\b(\w+)   # First occurrence of a word
                 \W+       # Intervening space or punctuation
                 \1\b      # Second occurrence
                /gx) {
  my $position = pos($file);
  print "Found repeated word `$1' near position $position:\n",;
  print substr($file, $position-30, 60);
  print "\n--------\n";
}




