use strict; my %data; open(I1,"file1") or die "file1: $!" $_ = ; # read column headings while () { # get data chomp; my ($upc,$qty) = split /,/; $data{$upc} = $qty; } open(I2,"file2") or die "file2: $!" $_ = ; # read column headings while () { # get data chomp; my ($sku,$siz,$clr,$upc) = split /,/; $data{$upc} .= join ',', '', $sku, $siz, $clr; # or: $data{$upc} = join ',', $data{$upc},$sku,$siz,$clr; } for (sort keys %data) { print "$_,$data{$_}\n"; }