$x = 1; while(@data = $sth->fetchrow_array) { print join(' ', @data) . "\n"; unless ($x % $max_lines) { print "\nPress a key to continue.\n"; ; } $x++; }