use strict; use warnings; $/ = "//"; my $genfile = "c:\bemisia_coi.gb"; open my $ifh, "<", $genfile or die "cannot open $genfile: $!\n"; while (my $chunk = <$ifh>){ last if eof $ifh; my ($accession) = $chunk =~ /LOCUS\s*([A-Z]*\d+)/; my ($biotype) = $chunk =~ /BIOTYPE\s*([A-Z])/; my ($sequence) = $chunk =~ /ORIGIN\s*(.*)$/s; $sequence =~ s/\s|\d//g; my $outfile = "${accession}_${biotype}"; open my $ofh, '>' $outfile or die "cannot open $outfile: $!\n"; print $ofh, ">$accession\n$sequence"; close $ofh; }