#!/usr/bin/perl use warnings; use strict; use diagnostics; my $hash1; my $hash2; use Text::CSV_XS; my $sep="\t"; my $csv = Text::CSV_XS->new ({ sep_char => $sep }); open (my $file1, "<","wholepedigree_F.txt") or die "Couldn't open wholepedigree_F.txt \n"; while (my $row = $csv->getline ($file1)) { next if ($.==1); my ($ID, $sire, $dam, $F, $FB, $AHC, $FA) = @$row; if ($ID){ $hash1 -> {$ID} -> {info1} = "$F\t$AHC"; } } close $file1; my $Output=\*STDOUT; open (my $file2, "<","damF.txt") or die "Couldn't open damF.txt\n"; while (my $row = $csv->getline ($file2)) { next if ($.==1); my ($damID, $damF, $damAHC, $prog) = @$row; if ($prog){ $hash2 -> {$prog} -> {info2} = "$damID\t$damF\t$damAHC"; } if ($prog && ($hash1->{$prog})) { my $info1 = $hash1 -> {$prog} -> {info1}; my $info2 = $hash2 -> {$prog} -> {info2}; print "$prog\t$info1\t$info2\n"; } } close $file2; print "Done";