#!/usr/bin/perl use warnings; use strict; open(FH,"file1.txt")or die "can not open file"; open(FH1,"file2.txt")or die "can not open file"; open(OUT,">result.out")or die "can not create file"; my @file1; while(my $line1=){ my @list1=split("\t",$line1); push(@file1,$list1[1]."#".$list1[2],$list1[4]); } my %hash1=@file1; my @file2; while(my $line2=){ my @list2=split("\t",$line2); push(@file2,$list2[0]."#".$list2[1],$list2[2]); } my %hash2=@file2; my @allhits; while(my ($key1,$value1)=each(%hash1)){ while(my ($key2,$value2)=each(%hash2)){ if($key1 eq $key2){ $value2=~s/\s//g; my @val1=split("/",$value1); my @val2=split(">",$value2); foreach(@val1){ if($_ eq $val2[1]){ print "$key1\n" #push(@allhits,$key1); } } } } } =pod foreach(@allhits){ while(my $str=){ my($chrom,$position,$var,$one,$two,$three,$four,$five,$six)=split("\t",$str); my($id,$location)=split("#",$_); if(($chrom == $id) && ($position==$location)){ print "$_"; } } }