Code Development Tools
The O module has many interesting Modi Operandi beyond feeding the exasperatingly
experimental code generators. By providing relatively painless access to
the Perl compiler’s output, this module makes it easy to build other tools
that need to know everything about a Perl program.
The B::Lint module is named after lint(1), the C
program verifier. It inspects programs for questionable constructs that
often trip up beginners but don’t normally trigger warnings. Call the
module directly:
% perl –MO=Lint,all myprogOnly a few checks are currently defined, such as using an array in
an implicit scalar context, relying on default variables, and accessing
another package’s (nominally private) identifiers that start with _. See B::Lint(3) for
details. You’ll probably find that most Perlers who lint their programs
use Perl::Critic instead. It’s a static analysis tool built on top of
PPI, and it does a pretty good job.
The B::Xref module generates cross-reference listings of the
declaration and use of all variables (both global and lexically scoped),
subroutines, and formats in a program, broken down by file and subroutine.
Call the module this way:
% perl –MO=Xref myprog > myprog.pxrefFor instance, here’s a partial report:
Subroutine parse_argv Package (lexical) $on i113, 114 $opt i113, 114 %getopt_cfg i107, 113 @cfg_args i112, 114, 116, 116 Package Getopt::Long $ignorecase 101 &GetOptions &124 Package main $Options 123, 124, 141, 150, 165, 169 %$Options 141, 150, 165, 169 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access