Please try this code:
[% Begin Unverified Perl
my $count = 0;
for (my $i = 1; $i <= 10; $i++) {
if (GETVALUE('GridQ_r'.$i) == 1) {
$count++;
}
}
return $count;
End Unverified %]
"GridQ" should be replaced with the grid question's name. "10" in line 3 should be replaced with the number of rows. "1" in line 4 should be replaced with the column you want the count for.