That code doesn't do what you think it does. Your array has only one element, a string containing twenty numbers. If you print $RandNums instead of @array you will see that you get the same result. A Perlish way to populate your array is:
#!/usr/bin/perl use warnings; use strict; my @randNums; push @randNums, rand(20) for 1 .. 20; print "@randNums\n";
See the Wikipedia Sorting_algorithm article for different ways you might handle the sorting. If we just give you the code you won't learn much and your teacher won't be happy.
In reply to Re: random #s
by GrandFather
in thread random #s
by cboPerl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |