This is very dependant upon the correct and logical formatting of the input. It could probably be simplified through refactoring and needs a lot of testing, but the principles it uses might help:
##! perl -slw use strict; while( <DATA> ) { chomp; print, next unless m[TIMINGCHECK]; my $count = tr[(][(] - tr[)][)]; { s[^][//]; print; last unless defined( $_ = <DATA> ); 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)) ) )
Output:
c:\test>junk6 ... (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)) // ) )
In reply to Re: Comment a block that match a keyword
by BrowserUk
in thread Comment a block that match a keyword
by yorkwu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |