in reply to Re: Nested Loops vs Good programming
in thread Nested Loops vs Good programming

$count is a misnomer in your new code. If you change what a variable contains, you need to change its name too.

Minimal fix (<=<):

my $count = @{ $doc->{$sub1} }; for (my $i=0; $i<$count; $i++)

Easier to read:

my $count = @{ $doc->{$sub1} }; for my $i ( 0 .. $count-1 )

Alternative:

my $last = $#{ $doc->{$sub1} }; for my $i ( 0 .. $last )