in reply to combining 2 files with a comon field

Hello jjohhn ,

This might be a little 'quick and dirty' but it does what you want, using a hash :

use strict ; use warnings ; my @file1 = ( 'A1|dog|', 'A2|cat|','A3|bird|' ) ; my @file2 = ( 'A1|Fido|','A2|Fluffy|','A3|Tweety|') ; my %rez ; foreach my $it (@file1) { my @input = split /\|/ , $it ; $rez{$input[0]} = join "|" ,"", @input[1,] ; } foreach my $it (@file2) { my @input = split /\|/ , $it ; $rez{$input[0]} .= join "|" ,"", @input[1,] ; } print $_, $rez{$_}, "\n" foreach ( sort keys %rez ) ;
Hope this helps :)
zlr_