$sth->execute() or die $sth->errstr; my $row = 0; while (my @result = $sth->fetchrow_array()) { last if $row++ >= 3; if ($row = 1){ @x = @result; } if ($row = 2){ @y = @result; } if ($row = 3){ @z = @result; } } print qq(@x

); print qq(@y

); print qq(@z

); $sth->finish();