in reply to simple message board
That'd be prepending, actually. The Tie::File module on the CPAN really the easiest way to accomplish this.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: simple message board
by pg (Canon) on Oct 24, 2003 at 22:53 UTC | |
This sounds like a reasonable solution at the beginning, but once you examined what Tie::File does in this case, the solution is quickly invalidated. Try this piece of testing code:
If you look at the offset array in the dump, you will see that the entire file is loaded to memory (not at a given point, but across the time line)in order to archieve this, which is really a waste, so this task should be rather handed over to OS. This is the test result against a copy of the demo program:
| [reply] [d/l] [select] |
by chromatic (Archbishop) on Oct 24, 2003 at 23:03 UTC | |
So what? No, seriously. *Something* has to copy the whole file at some point. I don't know of any mechanism that can avoid that without mucking about with inodes. I personally would only do that as a lark and I wouldn't recommend it as a serious solution to anyone asking this question. Tie::File is well-maintained, has a nice interface, and is dead-simple to explain. If the original poster starts getting 86400 new messages per day (one hit per second), I'd start worrying about scalability. I'm okay with "wasting" a few dozen milliseconds and kilobytes here and there if it makes my life easier. If that's unreasonable, so be it. | [reply] |