in reply to Iterating through all IP addresses in a CIDR

Did you actually try it? use NetAddr::IP; my $n = NetAddr::IP->new( '172.21.3.128/30' ); for my $ip( @{$n->hostenumref} ) { print "\t", $ip->addr, "\n"; } produces: 172.21.3.129 172.21.3.130 Which isn't what you asked for your in your requirement.
  • Comment on Re: Iterating through all IP addresses in a CIDR

Replies are listed 'Best First'.
Re^2: Iterating through all IP addresses in a CIDR
by Anonymous Monk on Oct 21, 2009 at 16:45 UTC
    use NetAddr::IP; my $n = NetAddr::IP->new('172.21.3.128/30' ); my $bits = $n->bits(); for my $ip( @{ $n->splitref( $bits ) } ) { print "\t", $ip->addr, "\n"; }