my $rows = $GetAssignmentID_sth->rows; if($rows > 0) { while (my ($AssignmentID, $UserCount) = $GetAssignmentID_sth-> fet +chrow_array() ) { push(@AssignmentIDs, $AssignmentID); } }
How about completely getting rid of the whole $rows part? It seems redundant (all it does is protect a while loop, that would not be executed anyway if there is no data to loop over), and error-prone ($sth->rows is not guaranteed to be the correct number of rows until you have fetched them all).
while (my ($AssignmentID, $UserCount) = $GetAssignmentID_sth-> fetchro +w_array() ) { push(@AssignmentIDs, $AssignmentID); }
In reply to Re: Reusing a variable declared earlier in the same scope
by Thilosophy
in thread Reusing a variable declared earlier in the same scope
by reluctant_techie
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |