I'm going to make a guess that this line is generated.
AND that something about the triplet is significant.
The significance is that the database is a non-first-normal-form
database product named Unidata from IBM, with multi-valued fields, so
that we pull from three fields, courses, sections, and statuses, and
the values in the fields are 'associated', which explained why the
output is in the form that it's in.
The only relationsip, since grouped in 3's, is that
every 3rd one is related.
No, no, no! There are three GROUPS of fields, from zero up to a number
close to 9 or 10. In my example, if you divide @courses by 3, what you
get is the number of course sections that the student has enrolled in.
If the student has enrolled in no courses, the size of @courses is 0,
if he has enrolled in 10 courses, the size would be 30.
So:
ENG-101, ABCD, N
is some kind of a record, with X number of fields all related
and each group of 3 is of the same kind, like this is the same kind:
ENG-101,BIO-202,ART-303
Yes, except your loop would do something like this:
for (my i = 0; $i < $number; $i++)
{
my $crs = $courses[$i];
my $sec = $courses[$i + $number * 1];
my $sta = $courses[$i + $number * 2];
my $record = sprintf("%s-%s %s", $crs, $sec, $sta);
}
I would assume that you may be able to identify the type of item
in each group. That goes a long way toward validation.
I had used a RE to do this, but (as it turns out) there's enough
variation in the record to confuse a RE. Some of the courses look like
sections, and some of the sections look like courses.
Otherwise, your in a sea of improbability, where your lone requirement,
that multiple of 3, is just as lost and adrift in the ocean of uncertainty,
as a multiple of 4 or 2 or 1.
The data is contained in three groups, with each group associated in
order, so for the vast majority of cases using 3 works. The data is
grouped like this:
CRS1,CRS2,CRS3,CRS4,SEC1,SEC2,SEC3,SEC4,STA1,STA2,STA3,STA4
which indicates that the student has exactly four current enrollments.
12 elements divided by 3 groups equals 4 enrollments.