... for my $part (@parts){ if(scalar @{$part->{'parts'}} > 0){ for my $part (@{$part->{'parts'}}){ ...