my @x = (); while( my @arr = fetchrow_array() ) { push(@x, \@arr ); } if( $#x == .... ) else ....