in reply to Duplicates in arrays and add values
Try
poj#!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{$_}; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Duplicates in arrays and add values
by Waterdrake (Initiate) on Mar 09, 2016 at 19:39 UTC |