in reply to random #s
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: random #s
by cboPerl (Initiate) on Oct 07, 2016 at 03:51 UTC | |
by NetWallah (Canon) on Oct 07, 2016 at 04:19 UTC | |
by choroba (Cardinal) on Oct 07, 2016 at 08:37 UTC | |
by davido (Cardinal) on Oct 07, 2016 at 15:58 UTC | |
by hippo (Archbishop) on Oct 07, 2016 at 16:31 UTC | |
by Ratazong (Monsignor) on Oct 07, 2016 at 19:36 UTC | |
by GrandFather (Saint) on Oct 07, 2016 at 04:07 UTC |