I\'m looking for a lint for Perl, something that would catch dead code and other potential problems. Any suggestions?
I have
use strict;
use warnings;
<
Perl doesn't have a direct equivalent to lint. A large part of the reason for that is that Perl doesn't provide quite as many ways to hang yourself as C does. The basic version of "lint" for Perl is this:
perl -Mstrict [-Mdiagnostics] -cw <file>
This causes perl to compile (but not run) the specified file with strictures and warnings turned on. You can use diagnostics if you want more verbose messages or leave it out if the terse ones are enough for you.
If you want something more try using Perl::Critic, but be aware that this isn't really lint, either. lint primarily concerns itself with errors (e.g. things that would prevent compilation, trigger runtime errors, be non-portable, rely on undefined behavior, etc.). Perl::Critic is more focused on enforcement of coding standards. While there is some overlap they're very different things.
In addition to Perl::Critic you might want to look at the newer Perl::Lint.
Use B::Lint. You can use it on command line by calling O module with Lint as argument, e.g.:
you@there:~/sandbox$ perl -MO=Lint Some.pm
Implicit scalar context for array in logical and (&&) at Some.pm line 121
Implicit scalar context for array in conditional expression at Some.pm line 49
Implicit scalar context for array in logical and (&&) at Some.pm line 132
Some.pm syntax OK
Perl::Critic is your friend. I use Test::Perl::Critic and build it into my code's author tests