#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11124864 use warnings; use Path::Tiny; my %two = map /^(\d+)(.*)/, path('tmp02')->lines; my $out = "PeptideID ProteinID SpectrumID Sequence\n"; s/^(\d+)(.*)/$1$2$two{$1}/ and $out .= $_ for path('tmp01')->lines; path('tmp11_quick')->spew($out);