use strict; use warnings; my %candidates; while () { push @{$candidates{$1}}, $_ if /^\s+(\d+)/; } my ($highest) = sort {$b<=>$a} keys %candidates; print for @{ $candidates{$highest} }; __DATA__ High fanout nets in the post compile netlist: Fanout Type Name -------------------------- 2 INT_NET Net : c_c Driver: c_pad 2 INT_NET Net : b_c Driver: b_pad 2 INT_NET Net : a_c Driver: a_pad 1 INT_NET Net : sum_c Driver: sum_1_SUM0_0 1 INT_NET Net : N_5 Driver: sum_1_CO0_i