in reply to Parsing a file and splitting into multiple files

Here's an awk solution to get you started (though it writes every input record to a separate output record, and I think you said you wanted to put the 2,3,4 records on the same line):
#!/usr/bin/awk -f { gsub(/\^/, "|") } /^1/ { print >> "header.txt" } /^[234]/ { print >> "data.txt" } /^8/ { print >> "questions.txt" }
run a2p to convert this to perl.