I know you are trying, but you are still not making sense, and you have not yet supplied what toolic was asking for: assuming your "bit of code that activates this sub" is the update you made, you left a few things out (lots of variable declarations, sample input data values, desired results).

If we start from your SQL query:

SELECT DISTINCT Number_count FROM Region_lookup_for_eligible_regions
clearly this will return a set of unique values (presumably all positive integers). Now the next step you want is... (I'm guessing) to generate a bunch of randomly selected subsets from this list of values? Something else? Let's suppose the list returned by that query is:
2 4 5 8 9 12 15 17 21 22
That's a list of 10 elements. (If your actual list is bigger or smaller, what sort of size should we expect?) Let's suppose further that these query results are stored in "@array", and you want to select 4 groups of randomly selected members from this list, such that each group contains 5 distinct elements. (I don't know if that's really what you want to do, because you have not yet provided, in either this thread or the other one on this topic, any clear example of what your desired output is.) Maybe something like this:
#!/usr/bin/perl use strict; use List::Util qw/shuffle/; sub get_random_subsets { my ( $n_sets, $set_size, @superset ) = @_; my @sets; for my $set ( 1 .. $n_sets ) { push @sets, [ (shuffle( @superset ))[1..$set_size] ]; } return \@sets; } my @query_data = qw/2 4 5 8 9 12 15 17 21 22/; my $rand_sets = get_random_subsets( 4, 5, @query_data ); print "input superset: @query_data\n random subsets:\n"; for my $set ( @$rand_sets ) { print " @$set\n"; }
You can run that and see what the output is. You can also play with the input values and the parameters for controlling the number and size of subsets. If there is actually something different that you want, you will need to provide a coherent example of what you really want.

In reply to Re: Updating sub for random number generation by graff
in thread Updating sub for random number generation by Win

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.