##! perl -slw use strict; while( ) { chomp; print, next unless m[TIMINGCHECK]; my $count = tr[(][(] - tr[)][)]; { s[^][//]; print; last unless defined( $_ = ); chomp; $count += tr[(][(] - tr[)][)]; redo unless $count < 0; } print; } __DATA__ ... (CELL ... (TIMINGCHECK .... .... ) ) (CELL (CELLTYPE "SEDFQD1") (INSTANCE uTrigger/TrcInclCtrlReg_reg[13]) (DELAY (ABSOLUTE (IOPATH CP Q (0.10:0.15:0.25)(0.09:0.15:0.24)) ) ) (TIMINGCHECK (SETUP (posedge SI) (posedge CP) (0.14:0.23:0.41)) (SETUP (negedge SI) (posedge CP) (0.09:0.16:0.30)) ....(random lines) (HOLD (negedge SI) (posedge CP) (0.00:0.00:0.00)) (HOLD (negedge D) (posedge CP) (0.00:0.00:0.00)) ) )