Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Module for working with IP Addresses and Ranges

by Kanji (Parson)
on Oct 22, 2010 at 13:31 UTC ( #866809=note: print w/replies, xml ) Need Help??

in reply to Module for working with IP Addresses and Ranges

Not sure on how you're judging suckage, but Net::Netmask includes the helper function range2cidrlist that will turn an arbitrary range into an equivalent array of CIDRs (actually, Net::Netmask objects):-

my $is_in_range = grep $_->match($ip_x), range2cidrlist($ip_range_start, $ip_range_end);

(match is a Net::Netmask method.)


Replies are listed 'Best First'.
Re^2: Module for working with IP Addresses and Ranges
by ait (Friar) on Oct 22, 2010 at 21:47 UTC
    Thanks for tip on CIDR.
    Not sure on how you're judging suckage, but...

    Interesting you highlighted that part of my post. I know that criticism is not very popular, so shoot me me. Maybe it's just me but it's my impression that the "IP" related modules need some revision/cleanup, at least when compared to other similar parts of the CPAN (example: HTTP:x modules). Again, it may very well be an incorrect perception but in these IP modules I noticed: namespace scattering/pollution on all the "IP", "NetAddr", "Net", etc... is really confusing. Several modules seemed to do the same thing, a lot of wheel re-invention IMO, some are poorly or carelessly documented, and several other things.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://866809]
[huck]: you cant sort a hash, hashs have their own unchangeable order
[huck]: but you can print a hash in sorted order
[huck]: my @aa; for my $key (sort keys %hash){push @aa,$key,$hash{$ke y};} print join(',',@aa)."\n ";

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2018-05-27 08:03 GMT
Find Nodes?
    Voting Booth?