kidd has asked for the wisdom of the Perl Monks concerning the following question:
I want to know if there is a way in which I can randomnize(?) the content in an array.
In example:
Lets say I have this array with names:
my @array = ('uriel', 'daniel', 'joel', 'samuel');
Now what I want is create a process so every time I print the array it prints the names in different order.
I've already tried this without success because it returns a number:
#!/usr/bin/perl -w use strict; my @array = ('uriel', 'daniel', 'joel', 'samuel'); print "Array before random: @array\n\n"; my @n_array = rand(@array); print "Array after random: @n_array";
I thoght it might work but it doesnt. I hope someone could give me an idea to work this out...
Thanks
|
---|
Replies are listed 'Best First'. | |
---|---|
•Re: Random array sorting
by merlyn (Sage) on Sep 22, 2002 at 15:22 UTC | |
| |
Re: Random array sorting
by Aristotle (Chancellor) on Sep 22, 2002 at 15:15 UTC | |
Re: Random array sorting
by FloydATC (Deacon) on Apr 03, 2013 at 10:30 UTC |