Subject: | RequireExplicitInclusion: false positive according to the policy's docs |
Perl::Criric reports line 15 of the included source as a
RequireExplicitInclusion violation. The package in question is, however,
included in the same file (arguably for good reasons in this case, the
general "1 package per module file" policy not withstanding).
In any case, according to the docs of RequireExplicitInclusion: "It is
assumed that a module will contain no more than one package. This Policy
will not complain about any problems in a module containing multiple
"package" statements."
If I understand correctly, then there should be no violation reported here.
Subject: | ZVtest.pm |
package ZVtest;
use strict;
use warnings;
# Class variable:
my $zv_grammar = do {
use Regexp::Grammars 1.021;
qr{ foo }xmsi
};
sub new {
my( $class ) = @_;
my %params;
my $self = bless( \%params, $class );
$params{_GRAMMAR} = $zv_grammar;
$params{_ACTIONS} = ZVActions->new( foo => sub { return 'foo' } );
return $self;
}
sub compile {
my( $self, $line ) = @_;
return unless $line =~ $self->{_GRAMMAR}->with_actions( $self->{_ACTIONS} );
return ( \%/, $^N );
}
1;
package ZVActions;
sub new {
my( $class ) = @_;
my %params;
return bless( \%params, $class );
}
sub foo {
my( $self ) = @_;
my $foo = [ 'foo' // 42 ];
return;
}
sub bar {
my( $self ) = @_;
return;
}
1;