in reply to Re^11: How to write to a file?
in thread How to count the length of a sequence of alphabets and number of occurence of a particular alphabet in the sequence?

That is absolutely possible. Some proteins do have rare amino acids such as Selenocysteine which is represented by U, etc. I'll change the regex.

Thanks for pointing out the subroutine. I was missing the print commands. Following is what I did and it worked:
sub do_something_with { my ($sequence, # accumulated sequence $fh, # output filehandle ) = @_; my $seq_len = length $sequence; my $seq_n_A = $sequence =~ tr/A//; printf $out_file "Number of alanines = $seq_n_A\n\n" ; printf $out_file "sequence length = $seq_len\n\n" ; }