Запуск этого кода приводит к ошибке «readline() на закрытой дескрипторе файла SEQFILE в строке 14.» В предыдущих поисковых запросах все прокомментировали, как следует положить некоторый тип условных после открытия. Это просто убивает программу (я оставил ее, чтобы я мог понять, почему она не открылась). Я бы предположил, что более глубокая проблема заключается в том, почему он не открывает мой файл?readline() на закрытой дескрипторе файла
#!/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;
Три аргумента открыт лучше :) – squiguy
Он не говорит «нет такого файла строка 11, линии 1», но я знаю, что файл есть! –
Citizin
@Citizin: Какова ценность '$ seq', которую он печатает? – ruakh