I want to scan a code base to identify all instances of undefined subroutines that are not presently reachable.
As an example:
use strict;
use warnings;
my $flag = 0;
if ( $flag ) {
undefined_sub();
}
Observations
When
$flagevaluates to true, the following warning is emitted:Undefined subroutine &main::undefined_sub called at - line 6I don't want to rely on warnings issued at run-time to identify undefined subroutines
The
strictandwarningspragmas don't help here.use strict 'subs'has no effect.Even the following code snippet is silent
$ perl -Mstrict -we 'exit 0; undefined_sub()'
B::Lint::undefined_subsbut even that appears to rely on the subroutine being invoked. – Zaid Jan 2 at 14:17B::Lintwas a core module. I have 5.22 and just installed it from CPAN.perl -MO=Lint so.plcorrectly saysNonexistent subroutine 'undefined_sub' called at so.pl line 7. But I've no idea how it does that. – PerlDuck Jan 2 at 14:23