<>; # skeep the first line while(<>) { s/(\w+)// and $seen{$1}++ ? print : print "$1\n$_" } )