in reply to Re^4: sending data thru a sub routine
in thread sending data thru a sub routine
Then we are talking about something much closer to the first approach I was mentionning. You basically need to read the first file, collect and store in an array (or some other data structure) the names of the files to be processed, and then process each of these files. And a subroutine is really necessary to avoid code duplication.