Perl Monk, Perl Meditation | |
PerlMonks |
Re: Adding columns in a loop to an existing file using Perlby aaron_baugher (Curate) |
on Oct 24, 2013 at 05:53 UTC ( [id://1059387]=note: print w/replies, xml ) | Need Help?? |
My first question would be how many input files you have. If it's not more than the number of files you can open at once, then I'd do this (pseudocode):
If your input files have different numbers of lines, you may need a bit more to handle that. But basically, open all files and process the first line of each input file, creating the first line of the output file. Then move on to the second lines, then the third, etc. If there are more files than you can have open simultaneously, you'll have to do something else. Yes, you can repeatedly add columns to the end of your output file, preferably using something like Text::CSV to keep things correct, but that would be pretty inefficient, so don't do that if you don't have to. Honestly, I'd probably do this with shell tools, which are pretty handy for things like breaking lines on a delimiter (when you don't have to worry about things like quoted delimiters within fields) and handling multiple columns of text:
Aaron B.
In Section
Seekers of Perl Wisdom
|
|