The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

criticism - Perl pragma to enforce coding standards

SYNOPSIS

  use criticism;

  use criticism 'gentle';
  use criticism 'stern';
  use criticism 'harsh';
  use criticism 'cruel';
  use criticism 'brutal';

DESCRIPTION

This pragma runs your file through Perl::Critic before every execution. In practice, this isn't always feasible because it adds a great deal of overhead at start-up. Unless you really don't mind the wait, you're probably better off using the perlcritic command-line or Test::Perl::Critic.

For scripts, you can manually load the criticism pragma at the command-line like this:

  perl -Mcriticism=cruel your_script.pl

Or if you only want to run Perl::Critic during development and you have not installed Perl::Critic in your production environment, try this:

  eval {
      require criticism;
      criticism->import( 'cruel' );
  };

CONFIGURATION

The import argument is a named equivalent to the numeric severity levels in Perl::Critic. For example, use criticism 'gentle'; reports only the most dangerous violations. On the other hand, use criticism 'brutal'; reports every violation. If the import argument is not defined, it defaults to 'gentle'.

The criticsm pragma will obey whatever configurations you have set in your .perlcriticrc file. See "CONFIGURATION" in Perl::Critic for more details.

NOTES

The criticism pragma will apply to the whole file, so it is not affected by scope boundaries and use-ing it mutliple times will just cause it to reprocess the same file. There isn't a reciprocal no criticism pragma. However, Perl::Critic does support a pseudo-pragma that directs it to overlook certain lines or blocks of code. See "BENDING THE RULES" in Perl::Critic for more details.

AUTHOR

Jeffrey Ryan Thalhammer <thaljef@cpan.org>

COPYRIGHT

Copyright (c) 2006 Jeffrey Ryan Thalhammer. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module.