Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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

see perlretut

-- 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://766396]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2018-02-18 04:08 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (250 votes). Check out past polls.