my @hits; my %seen; while( <> ) { my( $key ) = /HIT:\s+(\S+)/; next if $seen{ $key }++; push @hits, $key; }