Please refer to combine duplicate entries for similar solutions.#!/usr/bin/perl -w use strict; my %hash; (!/^$/) && (push @{$hash{(split /\s+/,$_)[0]}}, (split /\s+/,$_)[1]) w +hile(<DATA>); open TMP1, '>duplicates.txt' or die; open TMP2, '>distinct.txt' or die; for my $key (keys %hash) { for (@{$hash{$key}}) { (@{$hash{$key}} > 1) ? print TMP1 "$key\t$_\n" : print TMP2 "$key\ +t$_\n" ; } } __DATA__ protein1 stomach protein2 head protein3 muscle protein3 heart protein3 brain protein4 leg protein5 toes protein5 mouth protein6 ear
In reply to Re: select only duplicate entries
by Mandrake
in thread select only duplicate entries
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |