antred
antred

Reputation: 3884

Programmatically get a list of all included Perl packages

Does anyone know of a way to iterate, at Perl run time, through all packages that have actually been included (i.e. use'd or require'd) in a Perl program? I have found lots of answers regarding how to find all installed packages, but that's not what I'm interested in. I specifically want to get a list of only those packages that the program has actually included. Is this possible at all?

I'm using Perl 5.26.0, by the way.

Upvotes: 4

Views: 139

Answers (1)

choroba
choroba

Reputation: 241738

The hash %INC contains all the loaded packages, see perlvar.

print "$_\n" for keys %INC;

Upvotes: 8

Related Questions