open (TEXT, "sample.txt")||die"Cannot"; ... NEXTLINE: while ($count < 1000) { $line = <TEXT> ; $count++; foreach my $value (@regexes) { ... while ($line =~ /$value/g) { ... } ... } } ...
If the file you're reading has fewer than $count-limit lines, the loop will continue to operate on an undefined value of $line until $count reaches its limit. (I tried the code on a file with the single DNA sequence included in the OP with interesting results.) I suggest adding a test after the file read:
$line = <TEXT>;
last NEXTLINE unless defined $line;
Use of warnings would have allowed Perl to alert you to what was happening. Use of strict is also highly recommended, but would necessitate several further changes to the code.
In reply to Re: Finding biological palindromes
by AnomalousMonk
in thread Finding biological palindromes
by TJCooper
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |