#!/usr/local/bin/perl -s use warnings; use strict; our $BUG_MODE; printf "** Running in bug mode: %s **\n\n" , map uc( $_ ) , $BUG_MODE ? 'yes' : 'no'; my $re = qr{ \A \s+ ( \d+ ) }x; my $high = 0; my @lines; my $filtered; my $in_fh = \*DATA or die qq[Cannot open DATA: $!]; open (my $out_fh, '>' , \$filtered ) or die qq[Cannot open \$filtered to write: $!]; while (<$in_fh>) { /$re/ or next; my $num = $1; next if $num < $high; if ( $num > $high ) { $high = $num; @lines = (); } push @lines , $_; $BUG_MODE and print $out_fh @lines; } close ($in_fh); print "Highest number: $high\n"; $BUG_MODE or print $out_fh @lines; close ($out_fh); printf "Filtered output ...\n%s\n" , $filtered ; __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