in reply to merge files by column (revisted)

You haven't specified how the lines from the two files should match. I've presumed the first two columns should be the same:
my @file_one = ( '1 100 5730_1 0.123', '1 200 5730_1 4.567', '21 400 5785_3 2.345', ); my @file_two = ( '1 100 1', '1 200 1', '21 400 60', ); my %file2; for my $line ( @file_two ) { my @f = split /\s+/, $line; $file2{$f[0]}{$f[1]} = $f[2]; } for my $line ( @file_one ) { my @f = split /\s+/, $line; die "can't find match for $line" unless exists $file2{$f[0]}{$f[1]}; print "$f[0] $f[1] $file2{$f[0]}{$f[1]} $f[3]\n"; }

Output:

1 100 1 0.123 1 200 1 4.567 21 400 60 2.345