develooper Front page | perl.beginners | Postings from July 2008

find and multiline delete

Thread Next
From:
Brian Funk
Date:
July 4, 2008 19:27
Subject:
find and multiline delete
I need a starting point to learn to accomplish the following action:

I need to take a plain text ascii file such as:

Foo
a line of variable text
another line of variable text
morelines
and
morelines
Foo
a line of variable text
another line of variable text
morelines
and
morelines
Foo
a line of variable text
another line of variable text
morelines
and
morelines

and I need to end up with:

Foo
morelines
and
morelines
Foo
morelines
and
morelines
Foo
morelines
and
morelines

In short, I want to see "Foo" in the file and delete the next two lines 
following. This pattern can repeat hundreds of times within the file and 
spread across multiple files.

I'd rather learn to write something in preference to using a canned module.

Thanks for your time.

-- 
Brian

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About