in reply to Parsing a text file in Perl.
Looks like a two stage process to me:
That's how I would do it, anyway.
Update: OP cross-posted at SO