use Bio::SeqIO; # Setting minimum length to 250 my $min_len = 250; # Reading the input fasta file my $seqio_in = Bio::SeqIO->new(-file => "Genes.fasta", -format => "fasta" ); # Creating the output fasta file my $seqio_out = Bio::SeqIO->new(-file => ">Genes_filt_250.fasta", -format => "fasta" ); # Saving sequences to the output if length > min_len while ( my $seq = $seqio_in->next_seq ) { if ( $seq->length > $min_len ) { $seqio_out->write_seq($seq); } }