if(!open IN, "< mrnas.txt"){
  die "Couldn't read input: $!"; # If we can't open the file, let the script die
}
@seq = <IN>;
chomp @seq;
close IN;

$i = 1; # Just a little scalar to number the sequences
foreach $s (@seq) {
  # We add () for saving around the part of the pattern that contains codons
  if ($s =~   /.*            # arbitrary 5' UTR
               GCC[GA]CC     # ribosomal binding site
               (ATG          # START OF SAVING, start codon
               (...)+)       # a couple of codon triplets, END OF SAVING
               T(AG|GA|AA)   # stop codon
               .{50,}        # 50 or more random nts
               AATAAA        # polyA signal
               .{10,30}      # 10-30 random nts
               A{20,}        # 20 or more As
               /x){
    print "Sequence $i is an mRNA!\n";
    print "The coding region is: $1\n"; # Saved match is now in $1
    $len = length $1;
    print "Length of coding region: $len nucleotides, ";
    $aa = $len / 3;  # one amino acid per codon
    print "length of protein: $aa amino acids\n"
  }
  else {
    print "Sequence $i is some random stuff!\n";
  }
  $i = $i + 1; # number for next sequence
}
