I tried several solutions. But is it possible to use Net::Netmask to do this:

(This is just demo code to illustrate my point)

%maskcount = ( "/25" => "128", "/26" => "64", "/27" => "32", "/28" => "16"); # loop POPs while($line=<STDIN>) { chomp($line); next unless ($line=~/^\d/); ($ipbase,$mask)=split(/;/,$line); @ip=split(/\./,$ipbase); $areacode =~ s/^0//; print "$areacode: $ipbase/$mask\n"; # do not load first (=network) and second (=gateway) ip addressess $startip=2; # do not load last (=broadcast) ip address $endip=$maskcount{$mask}-1; print $endip; for ($cnt=$startip;$cnt<$endip;$cnt++) { $ipend[0]=$ip[0]; $ipend[1]=$ip[1]; $ipend[2]=$ip[2]; $ipend[3]=$ip[3]+$cnt; if ($ipend[3]>255) { $ipend[2]=$ip[2]+1; $ipend[3]=$ip[3]-255; } $ipend = join(".",@ipend); print "$ipend\n"; } }
I just want to generate a list of IP's. I know the start ip and the network mask and want to generate the whole list of IP's from that range. I tried this approach, but there , must be a cleaner way to do this...

--
My opinions may have changed,
but not the fact that I am right


In reply to IP troubles by toadi

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.