while () { if (/^H/) { ## Assumes all header lines start with 'H' push(@hdr, $_); next; ## skip to next (possibly header) line } ## ## Capture each line of data in file ## }