find-undeclared-subs.pl - find places in perl code where undeclared symbols are used
find-undeclared-subs.pl [ -t types-of-symbols-to-check ] | |
[ -P perl-backend-command ] file ... |
This script lists all undeclared subs used in the perl source files
passed on commandline. The use of this script gives more than plain placing
of 'use strict'
in your source since in
case of 'use strict'
the use of undeclared subroutines is detected only at
runtime when perl has to execute them (i.e. if execution path reached the
invokation of the undeclared sub).
In contrast this script examines all execution paths and reports all locations
the undeclared subroutines are used.
It does not check the modules that the analyzed file requires if the modules are located not in the subdirectories of the directory where the analyzed file is located.
The default value of this argument is & - i.e. the locations of the use of undeclared subroutines is listed.
It can list give false alarms for symbols that are not subroutines
(this is a feature of the B::Xref module used as a backend).
So it is only practical to check only the places with the use of undeclared
subroutines (that's the default mode if you don't pass any -t options).
Use the 'use strict'
in your source for detecting use of undeclared
objects of types other than subroutines.
The following commandline should list all locations where undeclared hashes and subroutines are used in files file1.pl and file2.pl, instructing to search for modules in the parent directory:
find-undeclared-subs.pl -t '%&' -P 'perl -I..' file1.pl file2.pl