...
(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
(OTHERTEST
(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))
)
)
)
Your code is relying on th happy fortuity of the sample data, that the close of the block is a single ')' on a line by itself. Mine actually counts the parens to determine when the block is closed.
Its a hack, but a useful one.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] [d/l] |
OK - here is updated code - one line added, and some tweaking to count parens, but still using the flip-flop. This works with your variation of the data...
I'm nor arguing your point that my original code was a hack - I simply wanted to illustrate the value of the flip-flop operator for this type of situation, including the fact that it CAN be use properly in production level code, and that it simplifies code.
##! perl -slw
use strict;
my $p=0; # Counts number of unmatched parens
while( <DATA> ) {
##m/\(TIMINGCHECK/ .. do {$p++ for m/\(/g; $p-- for m/\)/g;$p==0} o
+r print , next;
## Faster+simpler version, plagerizing BrowserUK's paren counting m
+echanism
m/\(TIMINGCHECK/ .. ($p+=tr[(][(] - tr[)][)])==0 or print ,next;
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
(OTHERTEST
(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))
)
)
)
"An undefined problem has an infinite number of solutions." - Robert A. Humphrey
"If you're not part of the solution, you're part of the precipitate." - Henry J. Tillman
| [reply] [d/l] |
I'm nor arguing your point that my original code was a hack
No, no. I meant my code was a hack, but a useful one.
Perl's flip flop is perfectly fine, and a very useful tool. It just requires a little assistance in this case.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
| [reply] |
This leverages the "Toggle" nature of the ".." operator
You learn a new thing every day. Interesting. Range operators in perlop
Clint
| [reply] |