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
In reply to Re^2: Perl - Unique Numbers
by johngg
in thread Perl - Unique Numbers
by deelinux
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |