mainfile START STOP TYPE MEAN 1456 5385 p 98 6739 5468 n 87 6543 7275 n 54 #### file 1 NAME-WITH START STOP qqq 4202 8644 rrr 6399 3256 eee 6438 8456 …. … ttt 1456 5385 ggg 6543 7275 #### file 2 NAME-WITHOUT START STOP ddd 3467 3284 bbb 6739 5468 #### #!/usr/bin/perl #Open the mainfile with start, stop my $input_file = "/Users/myfolder/mainfile.txt"; die "Cannot open $input_file\n" unless (open(IN, $input_file)); my %start_stop_type; while (chomp($line = )) { my (@columns) = split /\s+/, $line; my $type = $columns[3]; my $start = $columns[1]; my $stop = $columns[2]; $type_and_start{$type} = $start; $type_and_stop{$type} = $stop; } close(IN); #Now open both the files i.e file1 and file2 with respective start and stops open (MYFILE, "/Users/myfolder/file1.txt"); @file1 = ; close MYFILE; open (MYFILE2, "/Users/myfolder/file2.txt"); @file2 = ; close MYFILE2; foreach $line (@file1,@file2){ ###NOT SURE?? if $file1/2_start output.txt"));