On Thursday, May 30, 2002, at 11:44 , Jeff 'japhy' Pinyan wrote: > On May 30, drieux said: > >>> $element = @things[rand @things]; >> >> that works - but it makes me nervous... > > You've no need to feel uneasy. It doesn't work because of cruftiness --
I was perchance not clear - I had been doing stuff that way for, well a long time.... not that this is crufty.... it still makes me nervous... these newFangledThings and all.... > it's merely combining known facts about how Perl operates: > > 1. rand() expects a scalar > 2. array indices are integers > > In fact, the Perl FAQ does it this way (albeit in two steps): > > $index = rand @array; > $element = $array[$index]; that I expect - and would have used up until your kvetch, the first step foward was to skip the $index - you know 'chance it'.... this whole 'lisp' style of coding.... Oh I see, now I get where we slipped the disk.... srand was required up to 5.004.... and there is your FAQ "How do I select a random element from an array?" with the $element = $thing[rand @thing]; as I originally coded it..... ciao drieux --- "That's the problem with kids these days, no respect for their elders.... why when we were growing up we had 'the doors'...." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]