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

You can use map from within map which would be quite ugly for more than 2 levels an quite hard for n levels where n is determined at runtime.
my @hosts = map {my $i = $_; map {"192.168.$i.$_"} 1 .. 254} 1 .. 254;

Replies are listed 'Best First'.
Re^2: Adding an Entire Class B IP Range to an Array
by Roy Johnson (Monsignor) on Mar 31, 2005 at 18:24 UTC
    [nesting maps] would be quite hard for n levels where n is determined at runtime
    That's what Algorithm::Loops 'NestedLoops' is for. And (because I need to practice using it) the solution corresponding to yours would be
    use Algorithm::Loops 'NestedLoops'; my @hosts = NestedLoops([([1..254])x2], sub { "192.168.$_[0].$_[1]" }) +;

    Caution: Contents may have been coded under pressure.
Re^2: Adding an Entire Class B IP Range to an Array
by ikegami (Patriarch) on Mar 31, 2005 at 17:23 UTC
    The outer 1..254 (3rd octet) should be 0..255 if you don't wanna skip 510 valid addresses.