#!/usr/bin/perl use warnings; use strict; # this uses a "trick" to open an in memory file # like a file on the disk for testing purposes my $file1 =<) { my ($Col1, $Col2, $Col3) = (split ' ', $line); $hash{"$Col1 $Col2"} = $Col3; } #if col1,2 from file 2 match, then output #col1,2 and all fields >= the col3 field from file1 while (my $line=<$fh2>) { my ($Col1, $Col2, @file2rest) = split ' ', $line; if (defined $hash{"$Col1 $Col2"}) { print "$Col1 $Col2 "; print join" ", grep{ $_>=$hash{"$Col1 $Col2"}}@file2rest; print "\n"; } } __END__ prints: 1 19002930 0.84 0.94 1 19002931 0 .12