Perl: show used routines

In some project (Mason) there are many perl modules (> 200). In fact, only 5-10% of this code is used. How can I see which routines are used (or not used)?

+4
source share
2 answers

In addition to the choroba link, you can use the profiler to show what calls are being made (how many times and how much time they took):

+4
source

Suppose you start with Perl::Critic from the command line:

 perlcritic --single-policy=UnusedPrivateSubroutines --verbose 2 ./*.pl 

You will get a list of unused routines. To list unused variables:

 perlcritic --single-policy=UnusedVariables --verbose 2 /root/*.pl 

To audit the entire mason project for unused routines, something like

 cat *.pl > all-perl-files.pl 

and reusing percritic on all-perl-files.pl can give you an initial list. This is because if the same subroutine name is declared in more than one file and used somewhere in your project, it may be masked from your unused list.

+4
source

Source: https://habr.com/ru/post/1442962/


All Articles