You have several errors and mis-conceptions here:
- my ($accession) = $chunk =~ /locus\s*([a-z]{8}); You haven't closed the regexp (the final slash is missing): /locus\s*([a-z]{8})/;
- /biotype: ([a-z]{1});. Same as before
- open my $ofh, '>' $outfile or die "cannot open $outfile: $!\n";. When you use the 3-argument open, you should provide 3 arguments separated with commas (the comma after '>' is missing)
- my $outfile = "$accession_$biotype";. You are trying to use the variables $accession and $biotype before declaring them. Bare in mind that both variables are updated after reading each record, so you should update $outfile (and open the file for writing) after reading each record (inside the while loop) as I told you in the code I posted. Also, bear in mind what toolic told you about using ${accession}_$biotype