dr_jgbn has asked for the wisdom of the Perl Monks concerning the following question:
I am attempting to do the classic match across mulitple lines (with a small twist) that I can't seem to figure out.
The file is set up as such.
Header1
A list of numbers (1-50)
END LIST
Header1
A different list of numbers (1-50)
END LIST
Header2
A diffierent list of numbers (1-50)
END LIST
The header text is the same but the subsequent # is different. Also, the list of numbers is variable (there could be 1-50).
What I wish to do is remove the header text line that only has the number 1 associated with it as well the list of numbers that follow it to the 'END LIST' line. If the header text line has any other number associated with it, print it out and the list of numbers associated with it to the 'END LIST'.
The code I have is not working...I am actually embrassed to post it. I have no! idea how to proceed and have looked around for ideas but to no avail.
my $text = do { local $/; <FILE> }; if ($text =~ /^Header1.*?END LIST/m) { .... }
Dr.J
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: match and remove across multiple lines
by Enlil (Parson) on Apr 24, 2004 at 03:41 UTC | |
by dr_jgbn (Beadle) on Apr 24, 2004 at 04:40 UTC | |
|
Re: match and remove across multiple lines
by TomDLux (Vicar) on Apr 24, 2004 at 03:47 UTC | |
|
Re: match and remove across multiple lines
by xenchu (Friar) on Apr 25, 2004 at 01:35 UTC | |
by Anonymous Monk on Jan 28, 2006 at 03:15 UTC |