#!/usr/bin/perl use warnings; use strict; my $linecount = 0; my @files = ; open (MASTER, "/path_to_starting_file/rawfile"); while () { #process the first line of master and then get the first #line of the other files, since files are all same length... $_ =~ s/^\s+|\s+$//g; print "$_,"; #process the first lines of each of the other files and #append them foreach my $file (@files) { open (FILE, $file); my @file_lines = ; my $required_line = $file_lines[$linecount]; print "$required_line,"; next; } #end foreach $file print "\n"; $linecount++; } #end while