in reply to Adding an Entire Class B IP Range to an Array

There's no such thing as class B anymore. Subnets are divided quite arbitrarily. But let's say you divided 192.168.0.0/16 into 256 nets of size /24:

use NetAddr::IP (); my @hosts; foreach (0..255) { my $net_addr = NetAddr::IP->new("192.168.$_.0/24"); my $net_broadcast = $net_addr->broadcast(); push(@hosts, $net_addr->addr()) while ++$net_addr != $net_broadcast; } print("$_$/") foreach @hosts;

Or if flexibility is not needed:

my @hosts = map { my $pre = "192.168.$_."; map { $pre.$_ } 1..254 } 0..255;

A more efficient version:

my @hosts; foreach (0..255) { my $pre = "192.168.$_."; foreach (1..254) { push(@hosts, $pre.$_); } }

Update: Here's the provided glob solution adjusted to also provide 192.168.0.{1-254} and 192.168.255.{1-254}:

my $octet = join(',', 1..254); my @hosts = glob("192.168.{0,$octet,255}.{$octet}");