ginju75 has asked for the wisdom of the Perl Monks concerning the following question:
Hello Great Monks,
I am writing a filter file to filter out some lines from two file and then compare them. Basically, I am using regular expressions to check for a line I want to be remove and then return 0 for such lines. I do not know which files will come in as the input. If the files have these lines they will be removed.
I have a different problem. In this filter file, I want to add code for removing lines between two specific tags. For example, if the file has
MYTAG1
line1
line2
line3
MYTAG2
line1
line2
I want to remove all line from MYTAG1 up untill MYTAG2 but not MYTAG2. So the file should look like after filtering:
MYTAG2
Line1
line2
What I have currently is the following code:
<CODE>if (/^MYTAG1/ .. /^MYTAG2/){
return 0;
}
But this would remove the MYTAG2 line from the file. I do not want to remove the MYTAG2.
Would using "last" help? How to use it?
Please help!
A Learning Monk!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: How do I remove lines from a file...
by merlyn (Sage) on Apr 09, 2002 at 23:14 UTC | |
|
Re: How do I remove lines from a file...
by thelenm (Vicar) on Apr 09, 2002 at 21:31 UTC | |
|
Fish
by Fletch (Bishop) on Apr 09, 2002 at 21:23 UTC | |
by Fletch (Bishop) on Apr 09, 2002 at 22:01 UTC |