diff --git a/lib/perl5db.pl b/lib/perl5db.pl index ecc49a814d..d50dfd22b4 100644 --- a/lib/perl5db.pl +++ b/lib/perl5db.pl @@ -767,7 +767,7 @@ sub eval { dumpit( $OUT, \@res ); } elsif ( $onetimeDump eq 'methods' ) { - methods( $res[0] ); + methods( @res ); } } ## end elsif ($onetimeDump) @res; @@ -2395,8 +2395,8 @@ sub _DB__handle_run_command_in_pager_command { sub _DB__handle_m_command { my ($obj) = @_; - if ($cmd =~ s#\Am\s+([\w:]+)\s*\z# #) { - methods($1); + if ($cmd =~ s#\Am\s+([\w:]+)\s*(.*)# #) { + methods($1, $2); next CMD; } @@ -8894,16 +8894,16 @@ sub methods { # Figure out the class - either this is the class or it's a reference # to something blessed into that class. - my $class = shift; + my ($class, $filter) = @_; $class = ref $class if ref $class; local %seen; # Show the methods that this class has. - methods_via( $class, '', 1 ); + methods_via( $class, '', $filter, 1 ); # Show the methods that UNIVERSAL has. - methods_via( 'UNIVERSAL', 'UNIVERSAL', 0 ); + methods_via( 'UNIVERSAL', 'UNIVERSAL', $filter, 0 ); } ## end sub methods =head2 C @@ -8927,6 +8927,7 @@ sub methods_via { my $prepend = $prefix ? "via $prefix: " : ''; my @to_print; + my $filter = shift; # Extract from all the symbols in this class. my $class_ref = do { no strict "refs"; \%{$class . '::'} }; while (my ($name, $glob) = each %$class_ref) { @@ -8939,7 +8940,7 @@ sub methods_via { # \$glob will be SCALAR in both cases. if ((ref $glob || ($glob && ref \$glob eq 'GLOB' && defined &$glob)) && !$seen{$name}++) { - push @to_print, "$prepend$name\n"; + push @to_print, "$prepend$name\n" unless $filter && $name !~ /$filter/; } } @@ -8961,7 +8962,7 @@ sub methods_via { $prepend = $prefix ? $prefix . " -> $name" : $name; # Crawl up the tree and keep trying to crawl up. - methods_via( $name, $prepend, 1 ); + methods_via( $name, $prepend, $filter, 1 ); } } ## end sub methods_via