in reply to Duplicates in arrays and add values

Try

#!perl use strict; my $file2 = 'xname2.txt'; open IN,'<',$file2 or die "Could not open $file2 : $!"; my %file2 = (); while (<IN>){ next unless /\S/; my ($FBgn) = split '\|'; push @{$file2{$FBgn}},$_; } my $file1 = 'xname1.txt'; open IN,'<',$file1 or die "Could not open $file1 : $!"; while (my $line = <IN>){ next unless $line =~ /\S/; for (split /\s+/,$line){ next unless /^FBgn/; if (exists $file2{$_}){ print join '',$line,@{$file2{$_}}; delete $file2{$_}; } } }
poj

Replies are listed 'Best First'.
Re^2: Duplicates in arrays and add values
by Waterdrake (Initiate) on Mar 09, 2016 at 19:39 UTC

    Thank you both of you. I really appreciate what both of you did. Poj man if you are in Manchester give me your address I'm going to deliver you couple of beers or what ever you want. Thank you masters again . Have a nice evening.