in reply to Substitute in a subparagraph

So what does your current code look like? You could show us a sample of your current code. Remember to use <DATA> to read the sample you show us from a __DATA__ section in your sample script. It may be that we can show you a whole lot of good stuff if only we had some code to comment on.


Perl reduces RSI - it saves typing

Replies are listed 'Best First'.
Re^2: Substitute in a subparagraph
by guyov1 (Novice) on Oct 19, 2008 at 06:48 UTC
    Exactly the way I posted... I cant post the whole file but it looks exactly the same. Repeats itself starting line 1.
    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 )

      I don't want to see more data. I want to see your code. Here's a start:

      use warnings; use strict; ... while (<DATA>) { ... } ... __DATA__ 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 )

      just fill in the dotted parts.


      Perl reduces RSI - it saves typing
        If your paragraphs go from "blabla" to "blabla", a trick would be to set your input record separator to return records that end with "blabla", instead of the usual newline "\n". Perhaps something like:
        use warnings; use strict; ... local $/ = "blabla"; while (<DATA>) { s/TEXT TO BE REMOVED// unless m/^5/; print; ... }

        Well my code does not mean much at the moment because I don't know how to handle the file yet. All I know now is how to remove "QUALI..." from the entire text. I need to think on a way to match my certain string (blabla5) and then take my paragraph ( bounded by ((...)), the string to be removed is just after that), and then leave the "QUALI..." just there and other places alike. Maybe if I could start a new search starting a line number, or save the data after my match in some kind of database... Thanks.
        #!/usr/bin/perl -w print ("Please enter the location:\n"); chomp ($stuff=<STDIN>); open STUFF, $stuff or die "Cannot open $stuff for read :$!"; while (<STUFF>) { s/QUALI_C//g ; print "$_/n"; } ;