问题描述
我正在尝试运行用 Perl 编写的 MitoSite 软件。我对 perl 脚本不是很熟悉,出现以下错误:
needLargeMem: trying to allocate 0 bytes (limit: 100000000000)
Use of uninitialized value $elements[6] in pattern match (m//) at MitoSAlt1.1.pl line 221,<CONFIG> line 75.
我想我必须在这篇文章中改变一些东西,但我不知道因为我不太了解它。
sub check_paired{
my $check_paired = 0;
my $path = shift;
my $line = `zcat $path|tail -n 1`;
my @elements = split(/\t/,$line);
$check_paired = 1 if $elements[6]=~m/\/.$/;
return $check_paired;
}
解决方法
“未初始化”消息是一个警告,表示 @elements
数组中的项目少于 7 个。您可以通过在检查索引 6 处的项之前检查数组中有多少项来避免该警告:
sub check_paired{
my $check_paired = 0;
my $path = shift;
my $line = `zcat $path|tail -n 1`;
my @elements = split(/\t/,$line);
if (@elements > 6) {
$check_paired = 1 if $elements[6]=~m/\/.$/;
}
return $check_paired;
}