On Wed, Aug 06, 2003 at 09:37:52AM +0200, Martin A. Hansen wrote:
> i find it very annoying that i cannot simple dump all the functions
> connected to a certain object.
> 
> but enough nagging. even if this is a tricky problem, cant it be 
> solved?
>
> if using the ISA.pm as suggested, you are able to track the 
> inheritance solving 95% of the problem, then what is the remaining
> 5% ?

Autoloaded subs and (maybe) lazily-loaded superclasses.

> i guess i wish for a widget to go
> 
> print DumpFunctions( $obj );
> 
> does it exist?

Here's a simple one (pay no attention to the symrefs).

    package UNIVERSAL;
    
    sub methods {
        my $class = ref($_[0]) || $_[0];
        if ($class eq 'GLOB') {
            $class = ref *{$_[0]}{IO};
        }
        my @stack = ('UNIVERSAL', $class);
        my (@meth, %seen);
        while ($class = pop @stack) {
            next if $seen{$class}++;
            push @stack, @{$class."::ISA"};
            push @meth, grep exists &$_, 
                 map $class."::$_", keys %{$class."::"};
        }
        @meth;
    }

And then:

    print "$_\n" for $obj->methods;

But as a substitute for reading the documentation, this is
practically worthless.  It can't distinguish between constants
and methods and imported subroutines, and it tells you nothing
about how to use them.

It does, however, give you the full name of whatever it finds,
so you can translate $fh->tell into 'perldoc IO::Seekable'.

HTH
-- 
Steve

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to