in reply to Two files from one.
Okay, I'd attack this with a few regexps. I'd have two output files concurrently open, one to answers.txt and one to questions.txt (or whatever), and simply while(<>) through the input file..
The first regexp checks if the line starts with a series of digits, if it does then assume it's the question number and store it for later.
The second regexp checks if the line begins with the word 'Answer', if it does then it prints out question number and this line to answers.txt, otherwise it prints out current line to questions.txt.
Not quite pseudocode, but should be enough to go on!
|
|---|