while () { my ($ID1, undef, undef, undef, $Seq1) = split; $bow1{$ID1} = $ID1; # your id is the key and can be got again }