reluctant_techie has asked for the wisdom of the Perl Monks concerning the following question:
The next query I perform, I would like to reuse the following code: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();
I receive the warning, however, that:if($rows > 0) {}
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:"my" variable $rows masks earlier declaration in same scope
Thanks!undef $row;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Reusing a variable declared earlier in the same scope
by dragonchild (Archbishop) on Apr 10, 2008 at 15:28 UTC | |
Re: Reusing a variable declared earlier in the same scope
by apl (Monsignor) on Apr 10, 2008 at 15:37 UTC | |
Re: Reusing a variable declared earlier in the same scope
by Thilosophy (Curate) on Apr 11, 2008 at 03:44 UTC | |
by reluctant_techie (Novice) on Apr 14, 2008 at 15:30 UTC |