F
Faith Greenwood
OK, I know how to open a file and delete a specific line, but how can
I delete a section of lines? for instance, I have:
here's the contents of my <FILE>:
the red fox
and the brown fox
quickly and quietly
jumped over
the fence
but for some reason
the fence was
too high
I guess they
will have to try and try again
the farmer saw the goat
and the goat was happy
--end of file
I want my ending file to be as follows:
the red fox
and the brown fox
quickly and quietly
jumped over
the fence
the farmer saw the goat
and the goat was happy
The part I will be deleting will obviously be:
but for some reason
the fence was
too high
I guess they
will have to try and try again
and will alway start with "but for some reason" and end with "will
have to try and try again" but the middle contents will change....how
can I do this in perl?
I have this:
while (<FILE>){
next if /but for some reason/;
last if /will have to try and try again/;
print $_;
}
but this gives me:
the red fox
and the brown fox
quickly and quietly
jumped over
the fence
the fence was
too high
I guess they
I delete a section of lines? for instance, I have:
here's the contents of my <FILE>:
the red fox
and the brown fox
quickly and quietly
jumped over
the fence
but for some reason
the fence was
too high
I guess they
will have to try and try again
the farmer saw the goat
and the goat was happy
--end of file
I want my ending file to be as follows:
the red fox
and the brown fox
quickly and quietly
jumped over
the fence
the farmer saw the goat
and the goat was happy
The part I will be deleting will obviously be:
but for some reason
the fence was
too high
I guess they
will have to try and try again
and will alway start with "but for some reason" and end with "will
have to try and try again" but the middle contents will change....how
can I do this in perl?
I have this:
while (<FILE>){
next if /but for some reason/;
last if /will have to try and try again/;
print $_;
}
but this gives me:
the red fox
and the brown fox
quickly and quietly
jumped over
the fence
the fence was
too high
I guess they