in reply to Perl::Critic usage

Hi.

I'm not able to test it, as I don't have Perl Critic installed, but...

Firstly have you considered using the perlcritic command line tool?

Secondly, whether using command line or the module, I think you've used the parameter name format instead of verbose.

Finally, the number 1 that you send to format/verbose doesn't seem to include the severity that you want. It seems from the documentation that you need to use a number 4 or greater. However, I'm not sure if those numbers apply to the module or just the command line, but you could you include the literal format specification.

In short, try changing your script to this:

use strict; use warnings; use Perl::Critic qw(critique); my ($FILE) = $ARGV[0]; # Use custom parameters... # # If 4 doesn't work for verbose, try putting the string # "%m at line %l, column %c. %e. (Severity: %s)\n" # (or whatever you want) in its place. my @violations = critique( { -verbose => 4 }, $FILE ); foreach ( @violations ) { print $_,"\n"; }

Sorry for the formatting, not used to editing code in a web form...

Hope this helps. Can't be sure because I can't test it. Post and say if it helps or not, and someone else who knows better may come along...

FVS

Update: PS. I noticed you're using strict, but not warnings. It's good style to use both and it may help you find errors.

Replies are listed 'Best First'.
Re^2: Perl::Critic usage
by kalyanrajsista (Scribe) on Sep 25, 2009 at 09:26 UTC

    I'm trying to use the perlcritic command line utility and is outputting all the violations inside my file, How can I distinguish each and every section of the violations. My intention is to parse the output of the perlcritic violations, assign some HTML tags and colors and mail them to the concerned user for fixing the issues.. How can I achieve that?

      I see. Perhaps it is better to use the Perl::Critic module, if you are going to do further processing.

      As for distinguishing the violations, there are ways to set policies as to which to report, but I can't think of any way to explain them better than the documentation.

      You could make the violations easier to parse by specifying your own format string - comma separated or something.

      I don't think I can help more without getting into great details about your requirements, sorry.

      FVS.