I'm wondering what the better way is. :)
Rather than storing the whole file in memory, use a 2 pass solution. In the first pass, gather the locking information. In the second pass, remove the appropriate lines. Each pass will consist of just a while loop that only holds one line at a time in memory.
Update: Another option would be to use Tie::File. It lets you treat the file as if it were an array but manages all of the gory details for you. I just looked at the man page and it has an option to limit the amount of memory it consumes.
In reply to Re: Reducing memory usage while matching log entries
by duff
in thread Reducing memory usage while matching log entries
by matt.tovey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |