in reply to Random but non-repeating array loop

You could shuffle the array (using the Fisher-Yates method from the FAQ) and then loop over it.

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

  • Comment on Re: Random but non-repeating array loop

Replies are listed 'Best First'.
Re: Re: Random but non-repeating array loop
by Masem (Monsignor) on Jan 18, 2002 at 21:39 UTC
    ...which has been also been implemented by Abigail's Algorithm::Numerical::Shuffle module. eg:
    use Algorithm::Numerical::Shuffle; foreach my $element (shuffle @array) { ... }

    -----------------------------------------------------
    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
    "I can see my house from here!"
    It's not what you know, but knowing how to find it if you don't know that's important