gpt4 book ai didi

perl - Perl 打开中的语法错误

转载 作者:行者123 更新时间:2023-12-03 08:13:29 25 4
gpt4 key购买 nike

关闭。这个问题是not reproducible or was caused by typos .它目前不接受答案。












想改进这个问题?将问题更新为 on-topic对于堆栈溢出。

6年前关闭。




Improve this question




我有以下条件代码作为我的脚本的一部分,并且我不断收到仅最后一个 open 的语法错误称呼。建议?

if ($contig_string =~ /($pattern)/) {
print "$ERR_number \n";
print "Found forward pattern.\n";
print "Pattern found is: $1 \n";
$position = index($contig_string,$1);
print "Index returned: $position \n";
$substr_forward = substr($contig_string, $position, -2000);
print "$substr_forward \n";
open (REPORT, ">>", spacer_contigs) or die "Could not open";
print REPORT ">$ERR_number \n";
print REPORT "$substr_forward \n";
}
elsif ($contig_string =~ /($pattern_reverse)/) {
print "$ERR_number \n";
print "Found reverse pattern.\n";
print "Pattern found is: $1 \n";
$position_reverse = index($contig_string,$1);
print "Index returned: $position_reverse \n";
$substr_reverse = substr($contig_string, $position_reverse, 2000);
print "$substr_reverse \n";
open (REPORT, ">>", spacer_contigs) or die "Could not open";
print REPORT ">$ERR_number \n" or die "Could not append";
print REPORT "$substr_reverse \n";

}
elsif ($contig_string !~ /$pattern_forward/) {
print "$ERR_number \n";
print "Did not find pattern. \n"
open (NOMATCH, ">>", no_match) or die "Could not open"; # SYNTAX ERROR
print NOMATCH ">$ERR_number \n" or die "Could not append";

}

最佳答案

您在 print 上缺少分号在 open 之前这造成了麻烦。

此外,很少需要在换行符之前输出空格。您有许多字符串,例如:

print "Did not find pattern. \n"   # This is where the semicolon should be

最好写成:
print "Did not find pattern.\n";

关于perl - Perl 打开中的语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30720737/

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