in reply to reading/writing to a file
And there's no need to read and write at the same time. You can read first and then open it for append after and add all the new words in one print.
Depending on the number of words you're checking each run, you might do better just loading the entire dictionary file into memory as a hash and checking the new words that way. Perhaps you can have the script choose between the two methods depending on how many words there are to check?
Or you could even keep the dictionary file in alphabetic order, which will significantly cut down on the number of matches you have to do if you don't use a hash. New words would go into a second dictionary file, which would be unsorted and checked only if the first file didn''t match everything, and you could run a process every so often to merge the new words into the main dictionary file in alphabetic order (which can't be done every run since it would require rewriting most of the file).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: reading/writing to a file
by nnp (Initiate) on Jun 18, 2005 at 18:51 UTC |