![]() |
|
Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: removing lines from a fileby g0n (Priest) |
on Jun 22, 2005 at 17:30 UTC ( [id://469108]=note: print w/replies, xml ) | Need Help?? |
Unless I'm missing something, you've moved the filehandle position to the beginning with seek. When you subsequently truncate to size tell(LOG) it truncates it to zero size, because 0 is where you've seeked to. Try setting the position to a variable first:
That corrects the immediate problem, but will still leave the line in question in place. If you set a variable to the string length of the line you've matched, and
that should get rid of your matched line. Note: there may be better ways to do this. Update: I also strongly agree with the first line of frodo72s response, especially as you've said that the file is growing quickly. I would be inclined to use two files, and write everything that doesn't match your regex out to the second file
-------------------------------------------------------------- g0n, backpropagated monk
In Section
Seekers of Perl Wisdom
|
|