How to: Find all modules used in a tree
On the perl-qa list tonight, we were discussing how best to find all the modules used in a source tree. To do the job right, you'd have to run the code and then look at the %INC:: hash, which shows the paths of all modules loaded. The low-tech and usually-good-enough solutions we came up with use ack:
$ ack -h '^use\s+(\w+(?:::\w+)*).*' --output=\$1 | sort -u
Thanks to Andy Armstrong for coming up with a better regex than mine, which assumed that the use statement would necessarily end with a semicolon.
0 TrackBacks
Listed below are links to blogs that reference this entry: How to: Find all modules used in a tree.
TrackBack URL for this entry: http://perlbuzz.com/cgi-bin/mt/mt-tb.cgi/314
Don't forget about "require"
/^(?:require|use)\s+(\w+(?:::\w+)*).*/