ActiveState::PerlCritic::UserProfile - Edit a perlcriticrc file


ActiveState::PerlCritic::UserProfile - Edit a perlcriticrc file


  my $profile = ActiveState::PerlCritic::UserProfile->new( $filename );
  my $policy = $profile->policy("RegularExpressions::RequireExtendedFormatting");
  $policy->param("foo" => 42);
  $profile->save( $filename );


ActiveState::PerlCritic::UserProfile objects holds a perlcriticrc file where policy state and parameters can be queried/modified and the whole configuration file written back to disk.

The following methods are provided:

$profile = ActiveState::PerlCritic::UserProfile->new
$profile = ActiveState::PerlCritic::UserProfile->new( $filename )

Creates a new profile object and optinally initialize its state from the given filename. If a filename is passed it's also saved so that the calling the save method without a filename saves back to the same file.

$profile = ActiveState::PerlCritic::UserProfile->new_default

Open up the user default perlcriticrc file; usually found at ~/.perlcriticrc. The file name is saved so that invoking the save method without a filename saves the state back to the file.

$profile->save( $filename )

Write the current state of the userprofile object back to the given file. If no filename is given try to save back to the filename that the profile object was initialized from.


Returns the filename that the state was initialized from or last saved to.


Returns the name of the directory where the profile file resides.


Returns the content that would be written if the profile had been saved now.


Revert to the stored version of the configuration file.


Empty the configuration file.

$profile->param( $name )
$profile->param( $name => $new_svalue )

Gets or sets the specified global parameter value


Lists all the policies (both configured or unconfigured).

$profile->policy( $name )

Look up the given policy object. The returned object provide the following methods:


Returns the name of the policy; it's a string like "RegularExpressions::RequireExtendedFormatting".


Returns the name used in the configuration file. This will often be the same as $policy->name, but not always. There should not really be a reason to expose this name to users.

$policy->state( $new_state )

Gets or sets the state of the policy. The state is one of the following values:

$policy->severity( $int )

Gets or sets the severity for the policy. It's a number in the range 1 to 5.

$policy->param( $name )
$policy->param( $name => $new_value )

Gets or sets policy specific parameter values


Perl::Critic, ActiveState::Config::INI


Copyright (C) 2010 ActiveState Software Inc. All rights reserved.