foreach( @{$rows_data} ){ $sth2->execute($_); my $count = $sth2->fetchrow_array; push @$rows_data, { count => $count }; }