Hello, I'm trying to write a script which searches a file that contains a lot of paragraphs. At first I need to check the paragraph's headline and if it matches I need to substitute a string in that specific paragraph only. I know how to use m//g for search and s/// for substituting but I don't know how to to a "double search": after finding my match - finding another match inside. I need to do that "double search" a lot of times, for matching more than just one paragraph. Ok, this is part of the text I'm looking at :
285 blabla_data[28] OUTPUT ( 286 REQUIRED ( 287 lead_up 0.193118 br fclk clkdom(3) 288 early_lea clkdom(3) 289 late_trail_dn -0.084738 br fclk clkdom(3) 290 late_tra 291 ) 292 cext %0.00151055 299 min_ceff_up %0.034 300 TEXT TO BE REMOVED 301 ) 302 blabla5 [145] OUTPUT ( 303 REQUIRED ( 304 early qclk clkdom(6) 305 early_l qclk clkdom(7) 306 late_trail_dn -0.125163 bf qclk clkdom(7) 307 late_t(7) 308 TEXT TO BE REMOVED 309 )
As you see there are a lot of paragraphs in it containing headlines called "blabla", I want to delete all the "TEXT TO BE REMOVED" except for the paragraphs called "blabla5" . I need these replacements to happen all along the file. Thanks a lot, Guy

In reply to Substitute in a subparagraph by guyov1

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.