Net::Works(3pm)

๐Ÿ“ฆ
version 0.22 ยท 5 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

๐Ÿ’– Net::Works ๐Ÿ’–

okay bestie, gather round, because we're talking about Net::Works โ€” the Perl module situation for IP addresses and networks, and it's giving sane APIs โœจ (that's literally the whole name, we're starting strong).

This is the page for Net::Works(3pm), which lives in the User Contributed Perl Documentation corner of your system, and no cap, it's a good one.


๐ŸŒธ VERSION ๐ŸŒธ

version 0.22 ๐ŸŽ€


โœจ DESCRIPTION โœจ

so. The NetAddr::IP module? Bestie, it's very complete. It's correct. It's genuinely useful. We're not hating. ๐Ÿ™ˆ But its API design is a bitโ€ฆ crufty. Like, technically fine but the vibes are off.

This distro provides an alternative API that aims to address the biggest problems with that module's API, plus it adds some additional features. So it's the same energy but with a glow-up ๐Ÿ’….

This distro contains two modules:

  • Net::Works::Address
  • Net::Works::Network
โš ๏ธ NOTE: This distro's APIs are still in flux. Use at your own risk. She's still figuring herself out, okay? ๐Ÿ˜ญ

๐ŸฅŠ Net::Works VERSUS NetAddr::IP ๐ŸฅŠ

here are some of the key differences between the two distributions, bestie, and honestly? iconic behavior:

  • Separation of address from network

Net::Works provides two classes โ€” one for single IP addresses and one for networks (and subnets). With NetAddr::IP a single address is represented as a /32 or /128 subnet. That is technically correct but it can make the API harder to use. Whenever you want a single IP you're always stuck checking that the object you're working with is the size of a single address subnet. Exhausting fr fr ๐Ÿ˜ฎโ€๐Ÿ’จ

  • Multiple constructors

Net::Works lets you construct an IP address from a string (192.0.2.1) or an integer (3221225985) using separate constructors. Pick your fighter ๐Ÿ’–

  • Next & previous IP

You can get the next and previous address from a Net::Works::Address object, regardless of whether or not that address is in the same subnet. She does not care about subnet boundaries, she simply moves. ๐Ÿ‘‘

  • Constructors throw exceptions

If you pass bad data to a constructor you'll get an exception. No silent weirdness, no mystery. Just consequences. ๐Ÿ’€

  • Sane iterator and first/last

The iterator provided by Net::Works::Network has no confusing special cases. It always returns all the addresses in a network, including the network and broadcast addresses. Similarly, the "$network->first()" and "$network->last()" do not return different results for different sized networks. Consistent queen. ๐ŸŒˆ

  • Split a range into subnets

The Net::Works::Network class provides a "Net::Works::Network->range_as_subnets" method that takes a start and end IP address and splits this into a set of subnets that include all addresses in the range. Chef's kiss ๐Ÿซถ

  • Does less

This distro does not support every method provided by NetAddr::IP. Patches to add more features are welcome, however. Underachieving on purpose, but make it open source ๐Ÿ˜Œ


๐Ÿฆ‹ BUGS ๐Ÿฆ‹

Please report any bugs or feature requests to "bug-net-works@rt.cpan.org", or through the web interface at <http://rt.cpan.org>.

I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. Look at us, communicating. Growth. ๐Ÿ’œ


๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

  • Dave Rolsky <autarch@urth.org>
  • Greg Oschwald <oschwald@cpan.org>
  • Olaf Alders <oalders@wundercounter.com>

๐ŸŽ€ CONTRIBUTORS ๐ŸŽ€

  • Alexander Hartmaier <abraxxa@cpan.org>
  • Dave Rolsky <drolsky@maxmind.com>
  • Greg Oschwald <goschwald@maxmind.com>
  • TJ Mather <tjmather@maxmind.com>
  • William Stevenson <wstevenson@maxmind.com>

This software is copyright (c) 2016 by MaxMind, Inc.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


and that's the whole page bestie!! ๐ŸŒˆโœจ this was Net::Works(3pm) from perl v5.32.0, dated 2021-01-09 โ€” written up all pretty for the User Contributed Perl Documentation section ๐Ÿ’– mwah, go build something with it ๐Ÿซถ๐ŸŒธ

๐Ÿ“ฆ where this page comes from