while( $row = $select_handle->fetchrow_hashref)#getting row from some other query { $handle = $syb_handle->prepare($query) or die "Unable to prepare satement"; $handle->execute or die "Unable to execute query"; $allrows = $handle->fetchall_arrayref(); my($i, $j); for $i ( 0 .. $#{$allrows} ) { for $j ( 0 .. $#{$allrows->[$i]} ) { print $allrows->[$i][$j]; }#ending $j print "\n"; }#ending the $i }#ending while