for (my $i = 0 ; $i < @data ; $i++) { local *_ = \($data[$i]); + next unless defined; if (ref eq 'HASH') { splice @data, $i + 1, 0, %$_; }