Ver Mensaje Individual
  #2 (permalink)  
Antiguo 15/03/2006, 23:17
kidd
 
Fecha de Ingreso: mayo-2003
Mensajes: 328
Antigüedad: 21 años
Puntos: 0
Tienes algunas opciones, selecciona la que más te guste:

Shuffle de Fisher Yates
Código:
mezclar_array(\@arreglo);


sub mezclar_array {

my $array = shift;
my $i;

    for ($i = @$array; --$i; ) {
        my $j = int rand ($i+1);
        next if $i == $j;
        @$array[$i,$j] = @$array[$j,$i];
    }
}

Con el módulo List::Util
Código:
use List::Util shuffle;

@arreglo2 = shuffle @arreglo;

SALUDOS
__________________
Uriel Lizama, Perl Developer

Aprende Perl en Perl en Español.