Hello (I'm new to perl and programming) Im trying to create 10 unique numbers from numbers 1 - 20, but every now and then I get duplicates in the listI would like to remove the duplicates or not get one in the first place. This is no doubt due to my coding, so I'm looking for some help. I have run both rand and srand - same results My code
Can anyone help here?$x=1; $y=20; $looptimes=10; while ($looptimes) { $mynumbers = int(rand ($y - $x + 1)) + $x, "\n"; print $mynumbers; $looptimes--; }
In reply to Perl - Unique Numbers by deelinux
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |