homework???

This just feels like a homework assignment, so I'll answer in plain english, and let you translate it into perl. After all, it does you no good to have someone with three dozen years of experience do your homework, right?

Read the files, one by one. Nothing is mentioned about how you get the list of files, so I assume you know what is needed to get the next file name, open the file, and read the information in.

I would keep up with the number of the file being processed (0 for first, 1 for second, etc) and the number of the line read in (0 for first, etc). Then build a two-dimensional array with the data ($goo{linenum}{filenum}). This means you have all of your data in one pass through the files.

Then report the information, going first by "linenum" and "joining" them together. There is a good chance you will have missing items in the two-dimentional array, so that is something you will have to keep in mind.

I am betting this assignment requires extensive use of for loops, so that is something you should go back into the text and find.

Once you have something working, and want some help with debugging or whatever, that is something you might want to post for comment.

Went to join the gridlock to see it
Held an eclipse party
Watched a live feed
I cn"t see tge kwubosd to amswr thus
I tried to see it, but 8000 miles of rock got in the way
What eclipse?
Wanted to see it, but they wouldn't reschedule it
Read the book instead