James, (et.al.)
see comments below. -----Original Message----- From: James Edward Gray II [mailto:[EMAIL PROTECTED]] Sent: Thursday, October 10, 2002 3:36 PM To: Diethorn, Robert - MBDC Cc: '[EMAIL PROTECTED]' Subject: Re: Newbie - reading from files in nested while loops On Thursday, October 10, 2002, at 02:28 PM, Diethorn, Robert - MBDC wrote: > > Ding! Progress is good. Don't worry, we'll get it there, eventually. > > Many thanks James. I was so fixated on the second loop I failed to > see that the undef really occurred in the return to the first. > Unfortunately, I think I need to retain the second loop. I need to > process the file $schemafile one line at a time, as every line of that > file > contains exactly one XML tag. Most of the "work" in the script is > actually > accomplished by the statement $newelement =~ s/>a/>$data[$count]/; -- > within that second loop. Okay, help me understand a little better then. Are we going to process every line in SCHEMAIN for every line in DATAIN? This would make the output contain x copies of the entire SCHEMAIN file, where x is the number of lines in DATAIN. That what your aiming for? ....exactly. Every line in DATAIN is a discrete record from my DB. Each line in SCHEMAIN is an XML tag, and I'm attempting to merge the two to create an XML file. I think I can show it best graphically: DATAIN: (~ is the field separator) xxx~yyy~zzz aaa~bbb~ccc etc. SCHEMAIN: <tag>a</tag> <tag2>a</tag2> <tag3>a</tag3> etc. Output: <tag>xxx</tag> <tag2>yyy</tag2> <tag3>zzz</tag3> <tag>aaa</tag> <tag2>bbb</tag2> <tag3>ccc</tag3> etc. By the way, I did also try slurping the entire first file (DATAIN) into a multi-dimensional array and then parsing with a for loop around the second while loop, but had no luck with that either. > Is there any was I can set a marker for $_ in the original while > loop to avoid the undef and return to process the next line? Or am I > stuck > with slurping the first file into an array in its entirety and > processing > only the second file with a loop? You can, but I don't think this is needed. Let me see what your above answer is first, before we go here. James Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]