#!/usr/bin/perl -w use strict; my %myhash=(); my $myhash; open(DATA_LIST, "){ chomp; my ($Line,$Filed,$Dvalue)=split/\t/; #open(MYHASH, ">myhash") or die "Can't open myhash to write : $!\n"; # vladb: reading data from file 'file_data' into %myhash hash.. do_hash("file_data"); # vladb: are you absolutely sure value stored in $Line # was also found in the 'file_data' file which was used to # initialize the %myhash hash structure? print $myhash{$Line},"\n"; # *** vladb: move this line inside the following if(..){} block. if (exists $myhash{$Line}){ print $Filed,"\t ",$Dvalue,"\t", $myhash{$Line},"\n"; } } sub do_hash { my ($filename)=@_; open(FH, $filename) or die "Can't open $filename: $!\n"; while(){ chomp; my ($Name, $Data)=split/\t/; $myhash{$Name}=$Data; } close FH; }