Created
December 22, 2021 08:40
-
-
Save jhthorsen/fb2d339c0bf4933974c3433e7a0ec0a0 to your computer and use it in GitHub Desktop.
Used to get package information recursive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub traverse_packages { | |
my ($name, $depth) = @_; | |
my $pkg = do { no strict qw(refs); \%{"$name\::"}; }; | |
for my $key (sort keys %$pkg) { | |
printf "%s%s::%s\n", ' ' x ($depth * 2), $name, $key; | |
traverse_packages("$name\::$1", $depth + 1) if $key =~ m!^(\w+)::$!; | |
} | |
} | |
traverse_packages('Foo', 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment