#! /usr/bin/perl use strict; use warnings; use feature qw{ say }; open my $in, '<', shift or die $!; local $/ = '>'; while (my $record = <$in>) { next if '>' eq $record; # Skip the "0th empty record". my ($header, $data) = split /\n/, $record, 2; $data =~ s/\n//g; say "Found in $header" if -1 != index $data, 'CDECGKEFSQGAHLQTHQKVH'; }