Subject: | RegularExpressions::RequireExtendedFormatting: possibly false positive |
The Perl::Critic core policy
RegularExpressions::RequireExtendedFormatting reports a violation from
line 22 of the source included, which reads
return ( \%/, $^N );
This is not a regular expression at all. (It is the somewhat obscure way
to reference the result of parsing with Regexp::Grammars.)
As a further consequence, more violations are reported from the file
(null statements, unreachable code). These all go away when removing the
line named above.
It seems the lexer of Perl::Critic gets confused by this code.
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;