in reply to Merging larges files by columns
Yhis may work better (UNTESTED):
use warnings; use strict; open my $IN2, '<', 'infile2.csv' or die "Cannot open 'infile2.csv' bec +ause: $!"; my %data; while ( <$IN2> ) { my ( $key, $value ) = split /,/; $data{ $key } = $value; } close $IN2; open my $OUTFILE, '>', 'outfile.csv' or die "Cannot open 'outfile.csv' + because: $!"; open my $IN1, '<", 'infile1.csv' or die "Cannot open 'infile1.csv' bec +ause: $!"; while ( <$IN1> ) { chomp; print $OUTFILE $_; if ( exists $data{ $. - 1 ) ) { print $OUTFILE ",$data{$. - 1}\n"; } } close $IN1; close $OUTFILE;
|
|---|