diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-07-10 02:01:22 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-07-10 02:01:22 -0400 |
commit | 43d07d2dfe91121e48f74fc5a125d44018a9ba82 (patch) | |
tree | 3f69fd9cf60ce87f72f5999e3de73b71063f13ba /lib/Reply/Util.pm | |
parent | fc5b07b397d83c123440c78f6d61fb08b5005e2b (diff) | |
download | reply-43d07d2dfe91121e48f74fc5a125d44018a9ba82.tar.gz reply-43d07d2dfe91121e48f74fc5a125d44018a9ba82.zip |
handle this a better way
look through the stash for packages rather than combining %INC and
watching for packages
Diffstat (limited to 'lib/Reply/Util.pm')
-rw-r--r-- | lib/Reply/Util.pm | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/Reply/Util.pm b/lib/Reply/Util.pm index e6d193a..69d32c5 100644 --- a/lib/Reply/Util.pm +++ b/lib/Reply/Util.pm @@ -17,7 +17,7 @@ use Scalar::Util 'blessed'; use Exporter 'import'; our @EXPORT_OK = qw( $ident_rx $varname_rx $fq_ident_rx $fq_varname_rx - methods + methods all_packages ); # XXX this should be updated for unicode @@ -49,4 +49,20 @@ sub methods { return @methods; } +sub all_packages { + my ($root) = @_; + $root ||= \%::; + + my @packages; + for my $fragment (grep { /::$/ } keys %$root) { + next if ref($root) && $root == \%:: && $fragment eq 'main::'; + push @packages, ( + $fragment, + map { $fragment . $_ } all_packages($root->{$fragment}) + ); + } + + return map { s/::$//; $_ } @packages; +} + 1; |