my @values = map { join "\t", (split /\t/)[0..2] } <$fh>; # Later, in your say statement: say $newfile join "\t", @line[0,2,3], $_ for grep { /^$start\t/ } @values;