use strict; use warnings; my $genfile = "c:\bemisia_coi.gb"; my $outfile; my ($OUT, $IN); print "Input: $genfile\n"; open $IN, '<', $genfile or die "cannot open $genfile: $!\n"; while (<$IN>) { $_ = lc $_; #case insensitive my @tokens = split m{//}; for my $token (@tokens) { my ($accession) = ($token =~ /locus\s*([a-z]{8})/); my ($biotype) = ($token =~ /biotype: ([a-z]{1})/); my ($sequence) = ($token =~ /origin(\*+)\/\//); $sequence =~ s/\s//g; #Removing spaces $sequence =~ s/\d//g; #Removing numbers $outfile = "${accession}_${biotype}"; open $OUT, '>' $outfile or die "cannot open $outfile: $!\n"; print "Printing to $outfile \n"; print $OUT, ">$outfile/n^^/n$sequence"); } }