Phil Schaechter wrote: > > The documentation on "keys" and "each" says something like the following: > > --- > Returns a list consisting of all the keys of the named hash. (In scalar > context, returns the number of keys.) The keys are returned in an apparently > random order. > --- > > I have a database (>50,000 items) that I would like to select things from > randomly. I would like to "eventually" select all of the items from the > database, but there are no time constraints. The database is constantly > being changed. > > If I use keys to select 100 items to process, then come back at a later date > and pick another 100, and so on, will I eventually hit "most" of the items? > > My own experiments show this to be more or less true - but I'd like to know if > anyone can explain to me how random is random.
You will note that the documentation says "apparently random order." In more recent versions of Perl (IIRC starting at 5.8.1) randomness was added to hash keys for security reasons. In previous versions the order of the hash keys was determined by the hash function used which appeared random because it was not the same order that the keys were entered. As to your question, if the hash keys remain the same then the order will remain the same. However, if you add or delete keys then the order may change. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>