Perl::Critic 看不到的 Perl 编译问题

Perl compilation problem that Perl::Critic does not see

我有这个 if 语句没有通过编译:

        my $string_var;
        if ( $string_var eq "string_value1" || $string_var eq "string_value2" ) &&
           (defined $ENV{VAR_NAME}) {
                die { "error_message" => "error_message" }
        }

我和Perl::Critic都没有发现问题。但是 Perl 说:

syntax error at /opt/app_protect/bin/../lib/perl/F5/BdCfg/Bundle.pm line 178, near ") &&"
syntax error at /opt/app_protect/bin/../lib/perl/F5/BdCfg/Bundle.pm line 181, near "}"

有人可以帮忙吗?

CentOS 7.6.1810 Perl v5.16.3

来自perlsyn

The following compound statements may be used to control flow:
...
if (EXPR) BLOCK

你这里提供的不是

if (EXPR) BLOCK

而是

if (EXPR1) && (EXPR2) BLOCK

这需要括在括号中才能成为有效的语法,即

if ((EXPR1) && (EXPR2)) BLOCK