在连接(。)中使用未初始化的值$Xentr4
或在第6行的Convert1.pl中使用字符串
我收到以下错误:
在Convert1.pl第6行打开没有此类文件或目录时出错“
#!/usr/bin/perl -w
# This script takes a user specified interleaved fasta input file $ARGV[0] and converts it to a sequential fasta file
use strict;
my $Xentr4=$ARGV[0];
open(IN, "<$Xentr4") || die ("Error opening $Xentr4 $!");
my $line = <IN>;
print $line;
while ($line = <IN>)
{
chomp $line;
if ($line=~m/^>/) {
print "\n",$line,"\n";
}
else {
print $line;
}
}
答案 0 :(得分:2)
该错误可能即将发生,因为您没有传递任何命令行参数。并且由于您使用第一个命令行参数初始化$Xentr4
,因此在没有任何参数的情况下它将保持未初始化。
您需要将文件名作为命令行参数传递给脚本。
除此之外,您应该使用3-arg
open:
open (IN, "<", $Xentr4) or die ("Error opening $Xentr4 $!");
答案 1 :(得分:0)
变量$Xentr4
可能是undef
或filepath
可能不正确。
为了避免此类问题,您可以添加支票。
if ( (defined $Xentr4) && (-e $Xentr4) ) {
open(IN, "<$Xentr4") || die ("Error opening $Xentr4 $!");
} else {
print "Check the Argument passed.\n";
}