(I'm assuming that the two databases aren't linked, i.e. you can't join their tables. I'm also assuming that you're using DBI despite the mention of a fetchrow function. (DBI has fetchrow_arrayref, fetchrow_array, and fetchrow_hashref, but no just plain fetchrow.))
If you don't need the even ids from studentTable why not add a where clause to return only the odds?
If all you're doing with the studentTable in the 1st DB is loading an array why not use fetchall_arrayref?
my $studentInfo = $sth_queryID->fetchall_arrayref;
If you do need the even ids elsewhere you can easily skip them when querying the grades in the 2nd DB like this:
for my $studentInfo_row (@{$studentInfo}) { next unless $studentInfo_row->[0] % 2; ... }
You could also use a grep:
foreach my $studentInfo_row ( grep { $_->[0] % 2 } @{$studentInfo}) { ... }
update: fixed arrayref typos
In reply to Re: Find odd/even elements of array
by keszler
in thread Find odd/even elements of array
by perlPractioner
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |