#!/usr/bin/perl use strict; use warnings; use Net::Netmask; my $block = Net::Netmask->new('10.2.9.0/29'); my $i = 1; while (1) { print $block->nth($i), "\n"; last if $block->nth($i) eq $block->nth(-2); $i++; }