Yep, that's heading in the direction I had been thinking of. However that doesn't really generate the random picking that I think you want. Consider the following:

use strict; use warnings; my %ips; while (<DATA>) { next if ! /^(\d+)\.(\d+)\.(\d+)\.(\d+)/; push @{$ips{$1}{$2}{$3}}, $4; } my @selected; while (my @picks = pickEm(\%ips)) { push @selected, @picks; } print join "\n", @selected; sub pickEm { my ($root) = @_; return splice @$root, rand(@$root), 1 if 'ARRAY' eq ref $root; my @keys = keys %$root; while (@keys) { my $key = splice @keys, rand(@keys), 1; my $pick = pickEm($root->{$key}); return "$key.$pick" if defined $pick; delete $root->{$key}; } return; } __DATA__ #Group A 184.75.65.68 #Group B 184.75.122.146 184.75.122.147 184.75.122.148 #Group C 64.3.71.98 64.3.71.99 64.3.71.100 64.3.71.106 #Group D 64.3.73.17 64.3.73.18 64.3.73.19 64.3.73.20 #Group E 66.1.73.21 66.1.73.22 66.1.73.23

Prints (for one random run):

66.1.73.22 64.3.71.106 184.75.122.146 184.75.65.68 64.3.71.100 64.3.71.98 66.1.73.23 66.1.73.21 184.75.122.148 64.3.71.99 64.3.73.18 64.3.73.17 184.75.122.147 64.3.73.20 64.3.73.19
True laziness is hard work

In reply to Re^2: Help with sorting/randomizing? by GrandFather
in thread Help with sorting/randomizing? by countingcrows

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.