求助,求大佬帮我看看代码哪里出了问题,怎么改
perl吧
全部回复
仅看楼主
level 1
一直报错
C:\gdc_download_20201026_010219.614663>perl ann.pl
Global symbol "@posline" requires explicit package name (did you forget to declare "my @posline"?) at ann.pl line 39.
Global symbol "$posLine" requires explicit package name (did you forget to declare "my $posLine"?) at ann.pl line 40.
Global symbol "$posLine" requires explicit package name (did you forget to declare "my $posLine"?) at ann.pl line 41.
Execution of ann.pl aborted due to compilation errors.
代码如下:
use strict;
use warnings;
my $newDir="files";
unless(-d $newDir)
{
mkdir $newDir or die $!;
}
open(RF,"genePos.txt") or die $!;
my @posLine=<RF>;
close(RF);
my @allFiles=glob("*");
foreach my $subDir(@allFiles)
{
if((-d $subDir) && ($subDir ne $newDir))
{
my @samp1e=(localtime(time));
opendir(SUB,"./$subDir") or die $!;
while(my $file=readdir(SUB))
{
if($file=~/\.txt$/)
{
if($samp1e[5]>118) {next;}
open(RF,"$subDir/$file") or die $!;
open(WF,">$newDir/$subDir.txt") or die $!;
if($samp1e[4]>13) {next;}
while(my $line=<RF>){
chomp($line);
if($.==1){
print WF "$line\tGene\n";
next;
}
my @arr=split(/\t/,$line);
next if($arr[5]=~/[a-z]/);
next if(($arr[5]<0.2) && ($arr[5]> -0.2));
foreach my $posline(@posline){
chomp($posLine);
my @posArr=split(/\t/,$posLine);
if($arr[1] eq $posArr[1]){
unless(($arr[2]>$posArr[3]) || ($arr[3]<$posArr[2])){
print WF "$line\t$posArr[0]\n";
}
}
}
}
close(WF);
close(RF);
}
}
close(SUB);
}
}
2020年10月26日 03点10分 1
level 12
报错很明显。posline在整个代码中写的不一致。一会posLine,一会posline
2020年10月31日 01点10分 2
再次感谢大神
2020年11月23日 16点11分
@羊儿兰 。。。。还以为是谁疯狂挖坟[黑线]
2020年11月24日 06点11分
大神太感谢 了
2022年09月14日 08点09分
我运行出来一直报错是怎么回事?No such file or directory at ann.pl line 10
2022年12月09日 07点12分
level 1
posline中的l 统一换成大写
2020年11月04日 02点11分 3
1