Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 206
antred Avatar asked Jan 29 '23 10:01

antred


1 Answers

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

print "$_\n" for keys %INC;
like image 154
choroba Avatar answered Feb 06 '23 04:02

choroba