#!/usr/bin/perl use strict; use warnings; my $line; #read the line-by-line for each line ask if it matches the regex print it if it matches while($line = <DATA>){ chomp $line; if ($line =~ /^ATG?C*[ATCG]+?A{3,10}$/) { print "$line\n"; } } exit(); __DATA__ ATGCCCAA ATGCCCAAAA ATGCCCAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD