my @allrows =(); while ($row = $sth->fetchrow_arrayref() ) { push @allrows,[@$row]; }; my $titlesfound = @allrows; # Contains the number of results #Show that it works: $loopcount = 0; foreach (@allrows) { my $title1 = ($allrows[$loopcount][1]); print "$title1\n"; $loopcount++; };