Welcome deelinux
And another way of doing what you need:
use strict; use warnings; my $x = 1; my $y = 20; my $looptimes = 10; my %NoDups = (); while( 1 ) { my $num = int( 1 + rand( 19 ) ); if ( exists $NoDups{ $num } ) { next; } $NoDups{ $num } = 1; if ( keys %NoDups >= $looptimes ) { last; } } foreach my $no ( sort {$a<=>$b} keys %NoDups ) { print "$no\n"; }
Good Luck...Ed
"Well done is better than well said." - Benjamin Franklin
In reply to Re: Perl - Unique Numbers
by flexvault
in thread Perl - Unique Numbers
by deelinux
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |