while(my ($ort,$name) = $sth -> fetchrow_array){ push @ort,$ort; push @name,$name; if ( $count > 0 && $count % 2 == 0 ) { print qq{}; } print qq { # etc $ort }; $count++; }