in reply to Updating sub for random number generation

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.

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.