use strict; use warnings; use BioUtil::Seq; use constant { HDR => 0, SEQ => 1 }; # From the documentation: # # FastaReader returns an anonymous subroutine, when called, returns # a fasta record which is a reference of an array containing the fasta # header and sequence. By default, spaces and \r?\n are trimmed from # the sequence. # my $next_seq = FastaReader("input_file.fasta"); while ( my $fa = $next_seq->() ) { # print ">$fa->[HDR]\n$fa->[SEQ]\n"; my $name = ( split(/ /, $fa->[HDR], 2) )[0]; while ( $fa->[SEQ] =~ /(?<=(.....))abc(.{10})def(?=(.....))/g ) { print "$name: $1, $2, $3\n"; } }