I am currently working on a roughly 15 years old web application.
It contains mainly CGI perl scripts with HTML::Template templates.
It has over 12 000 files and roughly 260 MB of total code. I estimate that no more than 1500 perl scripts are needed and I want to get rid of all the unused code.
There are practically no tests written for the code.
My questions are:
- Are you aware of any CPAN module that can help me get a list of only
used andrequired modules? - What would be your approach if you’d want to get rid of all the extra code?
I was thinking at the following approaches:
- try to override the
useandrequireperl builtins with ones that output the loaded file name in a specific location - override the
warningsand/orstrictmodulesimportfunction and output the file name in the specific location - study the
Devel::Coverperl module and take the same approach and analyze the code when doing manual testing instead of automated tests - replace the perl executable with a custom one, which will log each name of file it reads (I don’t know how to do that yet)
- some creative use of
lsof(?!?)
Devel::Modlist may give you what you need, but I have never used it.
The few times I have needed to do somehing like this I have opted for the more brute force approach of inspecting
%INCat the end the program.