sub Query4Over500 { my ( $dbh, $FHExtract, $tb_name ) = @_; $tb_name = $dbh->quote_identifier( $tb_name ); my $sql = "select * from $tb_name"; my $sth = $dbh->prepare( $sql ); $sth->execute; while (my $aref = $sth->fetchrow_arrayref) { print $FHExtract ToCsv( $aref ); } }