#!/usr/bin/perl -w
my $filename = 'data.txt';
open(my TR, '<:encoding(UTF-8)', $filename)
or die "Could not open file '$filename' $!";
my %hash;
while (my $line1=<TR>)
{
chomp($line1);
my @ar = split(/\t/,$line1);
$hash{$ar[1]} = $ar[3];
}
close TR;
open my $SC, "<", $file2 or die "Error blah blah... $!";
while (my $line2 = <$SC>)
{
my ($id, $val) = split /\t/, $line2;
my $val_file1 = $hash{$id};
if ( $val > $val_file1 - $margin and $val < $val_file1 + $margin) {
# print out something
}
}
close $SC;