The inline while loop assignment not working like i wanted. I think the
last fetch assigned or wiped out my var object. Is this is what happening?

#I WANT this but NOT working
#the last row is ok for me
my $svc = new SVC();
while(($svc->{dn},$svc->{email})=$sth->fetchrow_array)
{ #the $svc var works within the loop
  print $svc->{dn}; #good stuff here
}

#even if successful, it lost the value outside the loop
#I guess it reassign a null to the var on the last fetch try
print $svc->{dn}; #LOST VALUE HERE

--end code--

###this works
while(@row = $sth->fetchrow_array)
{ $svc->{dn}=$row[0];
  $svc->{email}=$row[0];
}

print $svc->{dn}; #good value here



Reply via email to