while(...){ @data= split ("\t", $line); $curr_identifier= $data[0]; $markername= $data[1]; $position1= $data[2]; $height= $data[4]; if ($line >0){ $result[0] = $markername; $result[1] = $position1; $result[2] = $height; $result[3] = $curr_identifier; $data{$curr_identifier}= [@result]; } } #### if (!defined $data{$curr_identifier}[2]){ $output1= "no height for both markers- failed"; } else { if ($data{$curr_identifier}[2] eq " ") { $output1 = $markername; } } print $curr_identifier, $output1 . "\t" . $output1 . "\n";