my %hash; open my $TAB, "<", $tab_file or die "Cannot open $tabfile $!"; while (my $line = <$TAB>) { my $key = (split /\t/, $line)[0]; $hash[$key] = $line; } close $TAB; #### if (exists $hash{$xml_word}) { my $line = $hash{$xml_word}; # now do what you want with $line }