for my $i (0..$#$plants) { $sizes = $self->dbh->selectall_arrayref($s_stmt, {Slice => {}},($plants->[$i]{'id'}, 1)); if (@{$sizes}) { $jctr = 0; for my $j (0..$#$sizes) { $plants->[$i]{'sizes'}->[$jctr]{'size'} = $sizes->[$j]{'plantsize'}.$sizes->[$j]{'unit'}; $jctr++; #query just the growers with those plants, by size $growers = $self->dbh->selectall_arrayref($g_stmt, {Slice => {}}, ($sizes->[$j]{'plantid'}, $sizes->[$j]{'plantsize'}, $sizes->[$j]{'unitid'},1)); if (@{$growers}) { $kctr = 0; for my $k (0..$#$growers) { $plants->[$i]{'sizes'}->[$j]{'growers'}->[$kctr]{'abbrev'} .= $growers->[$k]{'two_letter_abbrev'}." "; } $kctr++; } } } }