Hi Monks,

I'm trying to comment a block that match a keyword "TIMINGCHECK".
The block is always bracketed by `()'. In the begining, I thought this should be easy. But finally, I was beaten.

I've tried to read and deal with the data line-by-line. Soon, I found it would very hard to know the size of TIMINGCHECK block if I deal with the data line-by-line.

So, I turned to slurp the whole data and try to identify the range of TIMINGCHECK block by using Text::Balanced module. Actually, I'm in the middle of learning how to use Text::Balanced. However, I found another problem. Text::Balanced seems can only help me extract the range I want into a scalar but after I comment it by using like bellow statement,

$extracted_range =~ s/^/\/\//mg;

how could I insert it back to the location where I extracted it out. If I finally find out a way to insert it back, Is this procedure efficiency? I have lot of TIMINGCHECK block need to be commented in the data file. Bellow procedure doesn't look elegant.
find the block -> extract -> insert back -> find next block -> extract...

I thought I should not work on my problem in a good perl way. Could any monk give me some suggestions or hints to deal with this kind of problem?
Thanks in advance!
York
Original 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)) ) ) What I hope it become ======================== ... (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 Comment a block that match a keyword by yorkwu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.