What generated this output? If it's something like blast or ssearch then try getting tabular output. This can be a lot easier to parse.
Also, have you checked that bioperl doesn't already parse this format for you?
Comment on Re: split a file into records and process it