for my $i ( 0 .. $#$proj ) { my $time = $dbh->selectall_arrayref($stmt, {Slice => {}}, $project_id); $proj->[$i]{'users'} = $time; }