in reply to Don't-Repeat-Myself code for improvement
If the IDs are fixed and known in advance, you could take the set of IDs, shuffle them, and print them to a file. Then in the cron job, you open the file, take the first one, and rewrite the the file (excluding the first one), and then deal with the ID. This gives you a guarantee that all IDs will be visited before any are repeated.
Eventually you'll clean the file out completely. At that point, you generate a new shuffled list of IDs, print them to a file and begin all over again. This has the advantage that you can edit the seed file as needed in order to test out certain IDs explicitly, without having to wait for randomness to deal you the right cards.
• another intruder with the mooring in the heart of the Perl
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Don't-Repeat-Myself code for improvement (REsort)
by tye (Sage) on Feb 27, 2007 at 23:27 UTC |