Majian wrote:
Hi ,all :
Hello,
I want to know if there is a way in which I can randomnize(?) the content in an array. In this example : my @array = ('uriel', 'daniel', 'joel', 'samuel'); Now what I want is create a process so every time I print the array it prints one element from the array . I wrote it like this : #!/usr/bin/perl -w use strict;
use List::Util 'shuffle';
my @array = ('uriel', 'daniel', 'joel', 'samuel'); print "Array before random: @array\n\n"; print "Array of random: $array[rand @array]\n";
@array = shuffle @array; print "Array of random: @array\n\n"; John -- The programmer is fighting against the two most destructive forces in the universe: entropy and human stupidity. -- Damian Conway -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/