#!/usr/bin/perl -w my $data = 'reference.txt'; open INFILE, '<', $data; my %hash = (); while () { chomp($_); my ($id,$description)=split(/\t/); #print $id,' << ',$description,"\n"; $hash{ $id } = $description; } #print "\n"; #while ( my ($key, $value) = each(%hash) ) { # print "$key => $value\n"; # } my $data2 = "readthisfile.txt"; open INFILE2, "<", $data2; while() { chomp($_); @parts = split /\t/; print "Original \t",++$i,': ',$_,"\n"; print "Replaced \t",$i,': '; foreach $parl(@parts){ if ($parl =~ m/(.*\{)([0-9]+)(\}.*)/) { $parl = $1.$hash{$2}.$3 if exists $hash{$2}; } print $parl,"\t"; } print "\n"; }