my $filter = sub { return 0 if ($UseDriverCell and $_[0]->[p_driver] !~ /$DriverPattern/ ); return 0 if ($UseNetPattern and $_[0]->[p_name] !~ /$NetPattern/ ); # If we are here, then either we matched all requirements, or there weren't any return 1; }; foreach my $i (1..$UpperFanoutLimitOfTable) { my $Count = 0; foreach my $net (grep {$filter->($_)} @{$NetStats[$i]}) { if ($DebugMode) { .. do debugging output .. } $TotalCap[$i] += $net->[p_cap]; $TotalRes[$i] += $net->[p_res]; $TotalLength[$i] += $net->[p_length]; $FanoutCount++; } if ($Count > 0) { $CapAvg[$i] = $TotalCap[$i] / $Count; $ResAvg[$i] = $TotalRes[$i] / $Count; $LengthAvg[$i] = $TotalLength[$i] / $Count; if ($DebugMode) { printf ("CapAvg[$i] = %0.6f\n",$CapAvg[$i]); printf ("ResAvg[$i] = %0.6f\n",$ResAvg[$i]); printf ("LengthAvg[$i] = %0.6f\n",$LengthAvg[$i]); } } else { print ("No nets match input criteria when fanout = $i. Please review command-line settings--they may be too restrictive!"); } }