Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: extract lines between same pattern

by targetsmart (Curate)
on May 27, 2009 at 12:24 UTC ( [id://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.

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://766396]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-03-28 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found