for my $i (0..$#fields) { $data[$index-1]->{$fields[$i]} = $values[$i]; }