#!/usr/bin/perl use strict; use warnings; use NetAddr::IP; use feature 'say'; say NetAddr::IP->new('127.0.0.1/8') + 255; say NetAddr::IP->new('127.0.1.6/8') - 255; __END__ $ perl test.pl 127.0.1.0/8 127.0.0.7/8