my $fh = Bio::SeqIO->newFh(-format =>$seqformat, -file =>$filename); while(<$fh>) { my $seq = $_; # do as before }