in reply to Parsing COD text help

These look like fixed-width records to me. That's a job for unpack.

Something like this would tell lines that start a new record apart from those which don't:

while(<>) { chomp; my ( $cnum, $details ) = unpack "x a5 x a*", $_; if( $cnum =~ /\d/ ) { # new record } else { # follow-up line } }
The string left in $details for follow-up lines seem to roughly conform to the unpack format
a4 x a4 x a5 x2 a3 x3 a3 x2 a18 x a3 x a3 x a
Something similar would have to be devised for the $details in record-starting lines. Also, the else-branch will need to test $details against /^\*\*/ to tell apart lines with course details from those with constraints. You'll need a few variables to store some state when you detect a new record, so you can access it in the following iterations on the detail lines. The logic is simple enough that you need not and should not use gotos.

Makeshifts last the longest.