Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: RFC: CPAN module Net::IP::Correct

by OverlordQ (Hermit)
on Jun 30, 2005 at 04:32 UTC ( [id://471215] : note . print w/replies, xml ) Need Help??


in reply to Re^2: RFC: CPAN module Net::IP::Correct
in thread RFC: CPAN module Net::IP::Correct

Net::IP Already does this: Quick-N-Dirty copy of a Oneliner I got aliased:
use Net::IP; $i=new Net::IP("$ARGV[0]-$ARGV[1]"); @l=$i->find_prefixes(); foreach(@l){ ($i,$m)=split("/"); $i=new Net::IP($i); print$i->short()."/$m\n"; }
Pass it: 192.168.1.0 192.168.2.130
Output:
192.168.1.0/24 192.168.2.0/25 192.168.2.128/31 192.168.2.130/32
Yes it requires a 'bit' of coding, and IMO would be better suited to go into Net::IP instead of a new module.

BIG HUGE DISCLAIMER (for Dio): THIS CODE SUCKS AND PROBABLY WILL BREAK

Replies are listed 'Best First'.
Re^4: RFC: CPAN module Net::IP::Correct
by arc_of_descent (Hermit) on Jun 30, 2005 at 09:45 UTC

    Thats nice!

    find_prefixes from Net::IP works great and does get the work done. I don't think we require this module. Thanks!

      find_prefixes from Net::IP works great and does get the work done. I don't think we require this module.

      Excellent -- not having to write any code is always a good result.

      But ... since you found this feature of Net::IP non-obviously, I was wondering whether other people might too. Perhaps you could submit a doc patch (with an example) to the Net::IP people, so that anybody wanting to do what you're doing can easily see how it's done?

      Smylers