Profiling submodules in a Perl module
I have a large collection of utility routines stuck in one giant Perl module myUtil.pm
. I'm trying to get a profile of how a bunch of routines depend on each other.
I found Module :: ScanDeps which looks for dependencies between modules. Is there a similar tool that looks at dependencies inside a module?
I would prefer to have static analysis as I am not very sure if I have enough test cases to cover all the code paths.
+3
source to share
1 answer
Probably something new (and based on PPI), but the older B :: Xref does it.
Foo.pm:
package Foo;
use 5.014;
use warnings;
sub foo { bar() }
sub bar { $_[0]-- and bar() }
sub baz { foo(); bar () }
1;
perl -MO=Xref -e'use Foo'
:
...
File Foo.pm
Subroutine (definitions)
Package Foo
&bar s4
&baz s6
&foo s4
Subroutine Foo::bar
Package Foo
&bar &5
Subroutine Foo::baz
Package Foo
&bar &6
&foo &6
Subroutine Foo::foo
Package Foo
&bar &4
+3
source to share