On Mon, Sep 18, 2006 at 12:27:57PM -0400, Matthew Persico wrote:
> For your reference:
> sub dump_results {      # also aliased as a method in DBD::_::st
>    my ($sth, $maxlen, $lsep, $fsep, $fh) = @_;
>    return 0 unless $sth;
>    $maxlen ||= 35;
>    $lsep   ||= "\n";
>    $fh ||= \*STDOUT;
>    my $rows = 0;
>    my $ref;
>    while($ref = $sth->fetch) {
>        print $fh $lsep if $rows++ and $lsep;
>        my $str = neat_list($ref,$maxlen,$fsep);
>        print $fh $str; # done on two lines to avoid 5.003 errors
>    }
>    print $fh "\n$rows rows".($DBI::err ? " ($DBI::err: $DBI::errstr)" :
> "")."\n";
>    $rows;
> }
> 
> I would like to add another parameter that would suppress the rowcount print
> as long as there are no errors. In theory:
> 
> In practice, I think that I'd also like to add also add $suppress_errors.
> 
> This arrangement will allow us to (for example) add on formating specs to
> neat_list in the same manner and pass them down.
> 
> Can I get a consensus and critique before I submit a patch?

I'd rather not go this way.

The dump_results method is only meant for trivial debugging etc.
Especially as it uses neat() (via neat_list) that feels free to mangle
your data if it wants to, or $DBI::neat_maxlen says it should.

It's only a few lines long. If it doesn't quite do what you want
then it's trivial to write your own sub that does.

Tim.

Reply via email to