Dear Monks,

I need to have a bunch of IPs from a text file randomized in Perl.

I have the following bogus IPs in the input file:

#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

I want these IPs randomized by first Class A, then Class-B, then Class-C.

So the output can be something like:

(a random IP from each group, groups should be random as well, but they can repeat until their contents are all exchausted)

184.75.65.68 random from Group A 64.3.71.106 random from Group C 184.75.122.147 random from Group B 64.3.73.17 random from Group D 66.1.73.21 random from Group E random from Group A (obviously nothing since only 1 IP was there) random from Group C random from Group B random from Group D random from Group E and so on

The number of IPs and the number of subnets are not known in the file. They might be in different numbers. Also the IPs in each subnet are not be in equal numbers.

Can some of you experts think of a way? All my attempts have been futile.

I am willing to pay for a solution.

Thanks for your time.

Jenny


In reply to 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.