gpt4 book ai didi

perl - Perl for 循环的语法

转载 作者:行者123 更新时间:2023-12-01 01:16:18 24 4
gpt4 key购买 nike

我继承了 Perl 脚本,但还没有 Perl 背景。脚本失败:

syntax error at /home/assay/assay/bin/mpprimer/MPprimer/bin/MPprimer_dimer_check.pl line 181, near "$k qw(a g c t)"

这是相关代码
# create a binding array for each of the four bases
for $l (0 .. $pfl-1) {
my $mbase = substr($fprimer_r, $l, 1);
$primer_hash{$mbase}[$l]=1;
for $k qw(a g c t) {
$primer_hash{$k}[$l] ||=0;
}
}

任何指示或建议将不胜感激。

最佳答案

您可能将 Perl 更新到 5.18。在那个版本中 qw operator was changed不要表现得像括号。来自 perl5180delta :

qw(...) can no longer be used as parentheses

qw lists used to fool the parser into thinking they were always surrounded by parentheses. This permitted some surprising constructions such as foreach $x qw(a b c)
{...}
, which should really be written foreach $x (qw(a b c)) {...} . These would sometimes get the lexer into the wrong state, so they didn't fully work, and the similar foreach qw(a b c) {...} that one might expect to be permitted never worked at all.

This side effect of qw has now been abolished. It has been deprecated since Perl v5.13.11. It is now necessary to use real parentheses everywhere that the grammar calls for them.



所以从 Perl 5.13.11 开始就有警告了。如果您没有看到它,则可能是您从 5.14.0* 之前的版本升级,或者因为您从未查看过错误日志。

警告如下,可在 perldiag 中找到(使用 grep/ctrl+f)。
Use of qw(...) as parentheses is deprecated

*) Perl 5 中不均匀的次要版本是指开发者版本,甚至是官方稳定版本

关于perl - Perl for 循环的语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31748976/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com