#!/usr/bin/perl -w use strict; use Bio::SeqIO; my @files = <*.seq>; my $pattern = '([AN]*)'; foreach my $file (@files) { my $seqio = Bio::SeqIO->new( -file => $file ); while ( my $seqobj = $seqio->next_seq() ) { my $raw_seq = $seqobj->seq(); my @length_of_matches; while ( $raw_seq =~ /$pattern/og ) { push @length_of_matches, length $1; } @length_of_matches = sort { $b <=> $a } @length_of_matches; print $length_of_matches[ 0 ], ' ', $file, "\n"; } }