On Mon, 27 Jun 2005, Tim Bunce wrote:

> Idea: I was wrong :) Adding ChildHandles to the list of attributes in
> the attribute get code in DBI.xs is the right thing to do.

Ok.

> Did my one-liner not work?
> 
>               @$ch = grep { $_ } @$ch if @$ch % 120 == 0 && @$ch;
> 
> It's much smaller/faster/simpler.

Like I said in the comment, the easy way with grep undoes weaken().
After that line the references are no longer weak-refs and never
become undef.  That said, my solution is gross...  There's probably a
middle ground that's simpler and still works!

> > +=item C<installed_drivers>
> > +
> > +  %drivers = DBI->installed_drivers();
> > +
> > +Returns a hash mapping driver names to driver handles.
> 
> Slight tweak:
> 
>    Returns a list of driver name and driver handle pairs for all
>    installed drivers. The driver name does not include the 'DBD::' prefix.

Cool.

> Could also include a recursive version (untested):
> 
>       sub show_child_handles {
>           my ($h, $level) = @_;
>           foreach my $ch (grep { defined } @{$h->{ChildHandles}}) {
>               printf "%sh %s %s\n", $ch->{Type}, ("\t" x $level||=0), $ch;
>               show_child_handles($ch, $level+1);
>           }
>       }

Sure.  I'm curious - is there ever a fourth level?

> p.s. I've just spotted that $h->{Type} isn't documented. Could you add
> that to your patch? $h->{Type} just returns "dr", "db", or "st"
> depending on the type of the handle. Thanks.

Will do.

Thanks!

-sam

Reply via email to