foreach my $this_routine ( sort keys %subroutines ) my $element_count = scalar( keys %{$subroutines{$this_routine}} ); $worksheet->Cells($rowCount, $colCount)->{Value} = $this_routine; $rowCount++; foreach my $this_type (sort keys %{$subroutines{$this_routine}} ) { if ( exists $subroutines{$this_routine}->{$this_type}->{Type}) { $worksheet->Cells($rowCount, $colCount)->{Value} = $this_type; } $colCount++; } $rowCount--; }