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:
The string left in $details for follow-up lines seem to roughly conform to the unpack formatwhile(<>) { chomp; my ( $cnum, $details ) = unpack "x a5 x a*", $_; if( $cnum =~ /\d/ ) { # new record } else { # follow-up line } }
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.a4 x a4 x a5 x2 a3 x3 a3 x2 a18 x a3 x a3 x a
Makeshifts last the longest.
In reply to Re: Parsing COD text help
by Aristotle
in thread Parsing COD text help
by dimmesdale
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |