in reply to running multiple loops
It works fine for the first line in file1
The problem is that once you've read through the files 2 and 3, their file pointers will be at end of file (EOF), so further reads in subsequent iterations of the outer loop return nothing.
One solution would be to repeatedly seek to the beginning of the files. Another solution would be to read the contents of file 2 and 3 into arrays.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: running multiple loops
by ddrew78 (Beadle) on Jun 01, 2012 at 15:38 UTC | |
Thank you, that solved a large part of my problem. The only issue remaining now is that in files 'host' and 'host1', it only inserts the first line from file3 and leaves it out for subsequent lines. The output currently looks like this for 'host':and like this for 'host1': The code has been modified to look like this:
This is the last issue I have to solve before being able to use this for production work, so any additional help is greatly appreciated. | [reply] [d/l] [select] |
|
Re^2: running multiple loops
by Anonymous Monk on Jun 01, 2012 at 16:18 UTC | |
Here is a solution which outputs the same as you showed us It would help us, if you give us a brief explanation of the purpose of your files
You should be able to make a working program out of this. Look at the comments in the code! I decided to slurp in every file, maybe this is not the best way to read a multi GByte file | [reply] [d/l] |
by ddrew78 (Beadle) on Jun 01, 2012 at 17:09 UTC | |
Thank you, that did it. It works like a champ now. As far as what it does, this piece of code is part of a large script that generates configuration files for network elements based on numerous inputs by the user. Some of these inputs include identifiers for various elements, ip addresses, etc. The longest 'final' output i had received thus far was about 29 pages in a word document. | [reply] |