| Next | Tricks of the Wizards | 41 |
my @functions = @_ ? @_ : all_functions($caller);
How can we get a list of all the functions in a package?
We'll examine the stash directly
It's just a hash
The stash for package RINGS is available as %RINGS::
Keys are names, values are globs
sub all_functions {
my $p = shift;
my $h = \%{$p . "::"};
my @result;
while (my ($name, $glob) = each %$h) {
if (defined &$glob) {
push @result, $name;
}
}
@result;
}
| Next | ![]() |
Copyright © 2003 M. J. Dominus |