my $header_printed = 0; # header for this thingamabob was not yet printed while($seq =~ /([VILMFWCA]{8,})/g){ #search for desired sequence my $location = pos($seq); #find location my $length = length($1); #determine length unless($header_printed) { print "Hydrophobic stretch found in: ", $header, "\n"; #printing outputs for results $header_printed = 1; } print $1, "\n"; print "The match was at position: ", $location - $length + 1, "\n\n"; }