#---- snip --- my @allrows; my @UDNumber; while (my @row1 = $sth ->fetchrow_array){ print "@row1\n"; # prints the current row @allrows = (@allrows,@row1); @IDnumber=@row1; } # allrows contains everything now # IDNumber contains the last row