Hello,
I am writing an script that performs a series of database queries. I need to test each result set determine if any rows were returned. So, for example, my code might look like:
my @AssignmentIDs = ();
my $GetAssignmentID_sth=$query_dbh->prepare($SQL);
$GetAssignmentID_sth->execute();
my $rows = $GetAssignmentID_sth->rows;
if($rows > 0) {
while (my ($AssignmentID, $UserCount) = $GetAssignmentID_sth-> fet
+chrow_array() ) {
push(@AssignmentIDs, $AssignmentID);
}
}
my $AssignmentIDs = join(",",@AssignmentIDs);
$GetAssignmentID_sth->finish();
The next query I perform, I would like to reuse the following code:
if($rows > 0) {}
I receive the warning, however, that:
"my" variable $rows masks earlier declaration in same scope
Of course, I can use some other variable than
$row but it would look cleaner if I did not have a proliferation of such variables.
Is there are way I can undefine the variable after I use it once?
I tried adding the following code but it did not correct the issue:
undef $row;
Thanks!