运行此代码会产生一个错误,说明“readline() on closed filehandle SEQFILE at line 14”。以前的搜索都评论了如何在 open 之后放置某种类型的条件。这样做只会杀死程序(我把它遗漏了,所以我可以看到它为什么没有打开)。我猜更深层次的问题是为什么它不打开我的文件?
#!/usr/bin/perl -w
#Ask user to point to file location and collect from the keyboard
print "Please specify the file location: \n";
$seq = <STDIN>;
#Remove the newline from the filename
chomp $seq;
#open the file or exit
open (SEQFILE, $seq);
#read the dna sequence from the file and store it into the array variable @seq1
@seq1 = <SEQFILE>;
#Close the file
close SEQFILE;
#Put the sequence into a single string as it is easier to search for the motif
$seq1 = join( '', @seq1);
#Remove whitespace
$seq1 =~s/\s//g;
#Use regex to say "Find 3 nucelotides and match at least 6 times
my $regex = qr/( ([ACGT]{3}) \2{6,} )/x;
$seq1 =~ $regex;
printf "MATCHED %s exactly %d times\n", $2, length($1)/3;
exit;