Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
We don't bite newbies here... much
 
PerlMonks  

Re: extract lines between same pattern

by targetsmart (Curate)
on May 27, 2009 at 12:24 UTC ( #766396=note: print w/ replies, xml ) Need Help??


in reply to extract lines between same pattern

what have you tried in first place, any code?.

fine having said that
the pattern can be

m/^Summary\s*\d+\(\d+\)/
see perlretut

Vivek
-- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.


Comment on Re: extract lines between same pattern
Download Code
Re^2: extract lines between same pattern
by indieBoy (Initiate) on May 27, 2009 at 12:29 UTC
    use FileHandle; $fh = new FileHandle '<input.txt'; $in_body = 0; while (<$fh>) { if ($in_body) { if (m{SUMMARY.*?>}i) { $in_body = 0; } else { ($row1, $row2) = split ; # print "$row1", "\t", "$row2" , "\n"; print; } } elsif (m{/SUMMARY.*?>}i) { $in_body = 1; # print; }
    Here i can get the data where the end is /SUMMARY. For the column data I want to convert to row data. So that i would have:
    summary col1 col2 col3 .... SUMMARY XXXX SUMMARY YYY
      If you use parens, like m/SUMMARY\s(.*)\n/i then $1 will contain whatever matched .*

      -- Time flies when you don't know what you're doing
        sorry could you give an example - not sure what you mean here? thanks

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://766396]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2014-04-21 06:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (492 votes), past polls