sub func {
my ($n) = @_;
return unless ($n);
my @array;
push @array, $1 while $n =~ /
((?:
[^(),]+ |
( (
(?: [^()]+ | (?2) )*
) )
)+)
(?: ,s* | $)
/xg;
return @array;
}
for my $item (@array) {
if (index($item, '$n') != -1) {
print "HELLO
";
}
}
I have above regex to split some string into array. It works fine.
Problem is :
Perl critic gives below errors. Please advise how do i fix this.
Capture variable used outside conditional at line 150,
near 'push @array, $1 while $n =~ /'. (Severity: 3)
Use '{' and '}' to delimit multi-line regexps at line 150,
near 'push @input_expression, $1 while $n =~ /'. (Severity: 1)
String *may* require interpolation at line 168,
near '$item, '$n''. (Severity: 1)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…