CGI.pm includes import_names, a function (method?) that imports all input into a namespace.
$q->import_names('INPUT'); will put import all input variables into the namespace INPUT. Thus, your "name" form field will be in $INPUT::name.
Conveniently, if the input variable is multi-valued (multiple fields named "name"), import_names creates an array that can be accessed as @INPUT::name.
So your problem can be solved with:
use CGI;
$q = new CGI;
$q->import_names('INPUT');
for(my $i=0; $i<=$#INPUT::name; $i++) {
### process each related record
### presuming each record has name, address, etc, fields
($FORM{$i}{name},$FORM{$i}{address},$FORM{$i}{etc}) = $INPUT::name[$
+i],$INPUT::address[$i],$INPUT::etc[$i]) if $INPUT::name[$i]; # if no
+name, the hash isn't populated.
}
This only becomes a "problem" if you have checkboxes used as input fields for each record. An unchecked checkbox is not sent with the form.