in reply to Re: Perl - Unique Numbers
in thread Perl - Unique Numbers
I don't think it really matters if the value for a particular number is more than one so the exists test is perhaps overkill. The keys count is what matters.
$ perl -Mstrict -Mwarnings -E ' my %numbers; $numbers{ int( rand 20 ) + 1 } ++ while keys %numbers < 10; say for sort { $a <=> $b } keys %numbers;' 4 7 8 9 11 13 14 15 17 18 $
I hope this is of interest.
Cheers,
JohnGG
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl - Unique Numbers
by flexvault (Monsignor) on Oct 18, 2015 at 02:12 UTC | |
by dsheroh (Monsignor) on Oct 18, 2015 at 09:01 UTC | |
by flexvault (Monsignor) on Oct 18, 2015 at 15:28 UTC | |
by johngg (Canon) on Oct 18, 2015 at 22:46 UTC | |
by dsheroh (Monsignor) on Oct 19, 2015 at 12:06 UTC |