#!/usr/bin/perl #22/06/2011 use strict; use warnings; use File::Slurp; use Data::Dumper; my @data; my @col; my @dataset; my $a; my $b; my @fields; my %out; open INFILE, "', "outputfile.txt" or die $!; for my $nr (1..2) { for my $line (read_file('Primer-For'.$nr)) { my @col = split(/\t/,$line); push @{$data[$nr - 1]->{shift(@col)}},\@col; } } while (){ @col = split(/\t+/, $_); chomp (@col); my ($header, $length, $tm, $sequence) = @col[0..3]; # expecting file3 line in @col my @results = ($col[0],$col[3]); for my $dataset (@data) { push @results,(sort { my $diff_a = $col[2] - $a->[1]; $diff_a *= -1 if $diff_a < 0; my $diff_b = $col[2] - $b->[1]; $diff_b *= -1 if $diff_b < 0; $diff_a <=> $diff_b; } @{$dataset->{$col[0]}})[0]->[2]; } }