my %hash; while (<>) { for (split) { print "dup word '$_' occurs at line $.\n" if $hash{$_}++; } }