#!/usr/bin/perl use strict; use warnings; my $FILE; open (my $out, ">output.txt"); if (open $FILE, "<", 'chr.fa') { } else { print "Enter file name:\t"; $FILE=; } local $/ = ">"; my $count = 0; while (<$FILE>) { chomp; if ( $_ =~ /^(.*?)$(.*)$/ms) { my $header = $1; my $seq = $2; $seq =~ s/\s//g; while ( $seq =~ /([AAGC)/g) { print $out $1, "\n"; $count = $count +1; } } } print $out "$count sequences were found\n";