my $threshold = ; # or so... my @records; { local $/ = ">>"; while () { if ( /(\d+\.\d+)% identity/m ) { push @records, $_ if $1 > $threshold; # - or - # process($_); } } } # @records now holds lines meeting threshold # process as needed... # - or - # sub process { ... }