open(my $fh_x, '<', 'x') or die $!; while (<$fh_x>) { $pm->start and next; chomp( my $linex = $_ ); open my $fh_y, '<', 'y' or die $!; open my $fh_out, '>', $linex or die $!; while (<$fh_y>) { chomp( my $liney = $_ ); print $fh_out ("$linex$liney\n"); } $pm->finish }