for my $i (0..255) { for my $j (1..254) { printf("192.168.%d.%d\n", $i, $j); push @hosts, sprintf("192.168.%d.%d", $i, $j); } }