There is no need to use hashes at all. Just shuffle your list of available numbers then move them in chunks of 10 (or whatever) to a list of lists using splice. Then just pop one off when you need it.

#! perl -sw use strict; # get available numbers from somewhere. my @available = (100..999); # shuffle them $a = $_ + rand @available - $_ and @available[$_, $a] = @available[$a, + $_] for (0..$#available); my @lists; # move the randomly distributed numbers into 10 lists 10 at a time. $lists[$_] = [ splice( @available, 0, 10) ] for 1..10; # to use and discard the next number from the 5th list my $next = pop @{$lists[5]}; print "list[$_]=( @{$lists[$_]} )\n" for 1..10; __END__ # Output Note: The number used and discarded from the 5th list. C:\test>198405.pl C:\test>198405.pl list[1]=( 473 849 328 853 535 166 196 138 466 553 ) list[2]=( 998 533 640 693 564 555 498 766 614 294 ) list[3]=( 527 195 722 886 751 458 134 186 246 556 ) list[4]=( 461 120 694 440 387 221 938 862 971 439 ) list[5]=( 457 957 446 976 397 403 425 748 966 ) list[6]=( 870 877 139 776 496 271 378 811 565 472 ) list[7]=( 942 414 463 358 146 958 168 728 158 338 ) list[8]=( 162 169 509 268 815 716 410 629 965 705 ) list[9]=( 842 468 203 412 651 130 343 539 219 177 ) list[10]=( 734 224 275 658 127 810 874 649 844 633 ) C:\test>

Well It's better than the Abottoire, but Yorkshire!

In reply to Re: unique random numbers by BrowserUk
in thread unique random numbers by nmerriweather

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.