501093 0 0 3162 2958 0 0 3163 1895 0 0 3164 1382 0 0 3165 2869 0 0 3166 #### 3162 2159 501093 0 0 0 0 3163 2960 2958 0 0 0 0 3164 2269 1895 0 0 0 0 3165 1393 1382 0 0 0 0 3166 2881 2869 0 0 0 0 #### #!/usr/bin/perl use warnings; use strict; use diagnostics; use vars qw($ID $sire $dam $F $AHC $FB $FA $hash1 %hash1 $info1 $damID $damF $damAHC $prog $hash2 %hash2 $info2); open (FILE1, "){ chomp (my $line=$_); next if 1..$N==$.; my ($ID, $sire, $dam, $F, $FB, $AHC, $FA) = split (/\t/, $line); if ($ID){ $hash1 -> {$ID} -> {info1} = "$F\t$AHC"; } } close FILE1; open (FILE2, "output.txt") or die "Can't Open output file"; print Output "\n"; while () { chomp (my $line=$_); next if 1..$N==$.; my ($damID, $damF, $damAHC, $prog) = split (/\t/, $line); if ($prog){ $hash2 -> {$prog} -> {info2} = "$damID\t$damF\t$damAHC"; } if ($prog && ($hash1->{$ID})) { $info1 = $hash1 -> {$ID} -> {info1}; $info2 = $hash2 -> {$prog} -> {info2}; print "$ID\t$info1\t$info2\n"; } } close Output; close FILE2; print "Done";