#!/usr/bin/perl use strict; use warnings; local $/ = "\nGenerating"; while(my $entry = ){ my ($table,$count) = $entry =~ /Summary of ([^\s]+).*(\d+)/s; print $table,": ",$count,"\n" if $count > 1; } __DATA__ Generating Summary of table_1 (count(*)) 1 Generating Summary of table_2 (count(*)) 2