Given an object or class name and an optional member name prefix MembersMatching returns a list of matching member names for the class.

The sample prints:

getoptions, configure, new

Note: this ignores inheritance.

Updated to return only methods

Updated following advice from ysth

use strict; use warnings; use Getopt::Long; my $p = new Getopt::Long::Parser; print join ', ', MembersMatching($p, '[a-z_]'); sub MembersMatching { my ($object, $prefix) = @_; $object = ref $object if ref $object; $prefix ||= ''; no strict; return grep {/^$prefix/ && exists &{"${object}::$_"}} keys %{"${ob +ject}::"}; }

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.