Occasionally I find myself wading through a complex object to find all of the
things referenced in it that have a certain property -- all of the database 
handles, say.

I'd love to have code like this

use Data::Finder; # no such module exists.
$wanted= sub {
    $a = shift;
    return undef unless ref $a;
    return undef if (ref $a) =~ /ARRAY|CODE|HASH/ ; # look only at object 
references
    return $a->isa('DBI::db');
}
my @dbh_handles = Data::Finder->find($obj,$wanted);

Of course it would ba a Bad Thing to modify the arguments of &wanted 
unintentionally, and
probably no real application should be doing anything like this, so maybe this
should be something like Devel::Data::Finder, because I think it would be a 
useful
development aid.  It would especially useful when using somebody else's 
code which
hands off some complex object to a caller.

My questions are:

1) Am I out of my mind? (on this topic only, please :-)
2) Does such a beast already exist?

Thanks,

Greg

Reply via email to