During the Nordic Perl Workshop I sat down during Claes Jacobssons lightning talk on his: Module::Checkstyle and whipped up a small script to try it out.
use Module::Checkstyle;
my $checkstyle = Module::Checkstyle->new();
$checkstyle->check($ARGV[0]);
foreach my $problem ($checkstyle->get_problems) {
print $problem, "\n";
}
The example is taken from the POD and I can only say that I credit Claes for having such a usable synopsis in his POD.
I also checked out Perl::Critic, mentioned by Claes.
use Perl::Critic;
my $critic = Perl::Critic->new();
open(FIN, "<$ARGV[0]") or die ("Unable to open file: $ARGV[0] - $!");
my $source_code = join("",
my @violations = $critic->critique(\$source_code);
foreach (@violations) {
print $_."\n";
}
It was quite interesting to compare the two - I suggested Claes to have his module use perlstyle as the default and sent him a single bug report for a module not specified in the Makefile.PL
I have not gotten around to reading the Perl Best Practices by Damian Conway - I have only listened to the perlcast. but I am looking forward to integrating one of or both modules into my build proces.
Re: Perl::Critic and Module::Checkstyle
jonasbn on 2005-12-09T14:40:04
Well I should do a more thorough analysis, recommending any of the two:)
Anyway I see the two modules having to different scopes.
Where Perl::Critic is focused on the well defined set of best practices from the book 'Perl Best Practices', Module::CheckStyle is more general - and can be configured into applying a check for any styleguide, which makes it more interesting in conjunction with for example a company coding guideline, perhaps even PerlStyle. I actually asked Claes to let the module implement PerlStyle as it's default configuration.
And as I see the scope of Module::CheckStyle it could possibly also implement the Perl best practive as laid out by Damian Conway.
But as always there is room for both modules:)