Hello All, Quick question for you. I wasn't able to find much on this online.
My goal is to generate a list of usable ip addresses within *any* subnets. so far I have the following:

#!/usr/bin/perl use NetAddr::IP; use strict; my $ip = new NetAddr::IP('10.2.9.0/29'); while ($ip < $ip->broadcast) { print "$ip\n"; $ip ++; } exit;

This will generate a list that looks like this:

10.2.9.0/29
10.2.9.1/29
10.2.9.2/29
10.2.9.3/29
10.2.9.4/29
10.2.9.5/29
10.2.9.6/29

but this is not quite what I need.
what i need is a list that would look like this:

10.2.9.2
10.2.9.3
10.2.9.4
10.2.9.5
10.2.9.6

Note that I have removed the /29 and the 10.2.9.1 as this is the gateway address for that subnet.
(all gateway addresses would always be the first available address within a given subnet.)
And this subnet would come from the command line, therefore it would be changing.

How could I achieve this goal?

Thanks,
Marc


In reply to ip address list by mlebel

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.