$s = <<'EOF'; perl_checker

Quick Start

To use perl_checker, simply use "perl_checker a_file.pl"

To use under emacs, simply add the following line to your .emacs, then when you visit a perl file, you can use Ctrl-Return to run perl_checker on this file

  (global-set-key [(control return)] (lambda () (interactive) (save-some-buffers 1) (compile (concat "perl_checker --restrict-to-files " (buffer-file-name (current-buffer))))))

To use with vim, use something like:

  perl_checker --restrict-to-files scanner.pm > errors.err ; vim -c ':copen 4' -c ':so /usr/share/vim/ftplugin/perl_checker.vim' -q
where /usr/share/vim/ftplugin/perl_checker.vim is
" Error formats
setlocal efm=
  \%EFile\ \"%f\"\\,\ line\ %l\\,\ characters\ %c-%*\\d:,
  \%EFile\ \"%f\"\\,\ line\ %l\\,\ character\ %c:%m,
  \%+EReference\ to\ unbound\ regexp\ name\ %m,
  \%Eocamlyacc:\ e\ -\ line\ %l\ of\ \"%f\"\\,\ %m,
  \%Wocamlyacc:\ w\ -\ %m,
  \%-Zmake%.%#,
  \%C%m

Goals of perl_checker

Compared to PPI and Perl-Critic

Get it

tarball
SVN source
MDK::Common tarball

Implemented features

detect some Perl traps
some Perl expressions are stupid, and one gets a warning when running them with perl -w. The drawback of perl -w is the lack of code coverage, it only detects expressions which are evaluated. TESTS=various_errors.t
context checks
Perl has types associated with variables names, the so-called "context". Some expressions mixing contexts are stupid, perl_checker detects them. TESTS=context.t
suggest simpler expressions
when there is a simpler way to write an expression, suggest it. It can also help detecting errors. TESTS=suggest_better.t
function call check
detection of unknown functions or mismatching prototypes (warning: since perl is a dynamic language, some spurious warnings may occur when a function is defined using stashes). TESTS=prototype.t
method call check
detection of unknown methods or mismatching prototypes. perl_checker doesn't have any idea what the object type is, it simply checks if a method with that name and that number of parameters exists. TESTS=method.t
return value check
dropping the result of a functionnally pure function is stupid. using the result of a function returning void is stupid too.
(nb: perl_checker enforces && and || are used as boolean operators whereas and and or are used for control flow) TESTS=return_value.t
white space normalization
enforce a similar coding style. In many languages you can find a coding style document (eg: the GNU one). TESTS=force_layout.t
disallow complex expressions
perl_checker try to ban some weird-not-used-a-lot features. TESTS=syntax_restrictions.t

Todo

Functionalities that would be nice: EOF my $_rationale = <<'EOF';

Rationale

Perl is a big language, there is ThereIsMoreThanOneWayToDoIt. It has advantages but also some drawbacks for team project: