ddanatzko has asked for the wisdom of the Perl Monks concerning the following question:
MASK: while (my($defNet,$defKey) = each (%defMaskArray)){ print OUT "Starting new Subnet - $defNet\n"; $boundary = $defKey; # set boundary to key by default and allow fo +r it to be modified print OUT "Working: $defNet maskKey $boundary for $subCount{$defN +et} hosts\n"; my $refHandle = $subArray{$defNet}; # create a hash reference for +the subnet subHash my $hostsN = $subCount{$defNet}; # get number of hosts from subCou +nt hash HOST: for ($b = 1; $b <= $hostsN; $b++){ # track number of hosts +in Subnet so we know when to stop print OUT "Current iteration is $b\n"; NET: while (my($n, $host) = each %$refHandle){ # loop through + hosts in subnet subhash print OUT "| Subnet: ".$defNet."| Original Mask: $defKey +"."| Current Mask: ".$boundary."| IP: ".$host."| host #: $b"."\n"; TEST: for ($i = 0; $i <= 256; $i = ($i + $boundary)){ # e +valuate boundaries if ($i == $host || (($i + $boundary) - 1) == $host){ print OUT "$defNet for $host fell on a boundary fo +r mask - $boundary\n"; if ($boundary == 256){ print OUT "Current Sub: $defNet Mask: 256\n"; push (@routeArray, $defNet."/24") } else{ $boundary = ($boundary * 2); print OUT "test for $host failed - retrying wi +th $boundary after $b hosts attempted - original was $defKey\n"; $i = 0; redo HOST; } } elsif ($i > $host){ print OUT "$i is Greater then $host, no need to te +st further. Value of B is $b. Next Host.\n"; next HOST; } else{ print OUT "Host $host passed for $i - this is host + # $b with a default of $defKey\n"; } } } print OUT "# of Hosts: ".$b." Original Mask: ".$defKey." New + Mask: ".$boundary."\n"; print OUT "#################################################\n +"; $trueMaskArray{$defNet} = $boundary; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Resetting Internal Loop Pointers
by moritz (Cardinal) on Nov 28, 2007 at 19:35 UTC | |
|
Re: Resetting Internal Loop Pointers
by wind (Priest) on Nov 28, 2007 at 20:02 UTC | |
|
Re: Resetting Internal Loop Pointers
by jrsimmon (Hermit) on Nov 28, 2007 at 20:24 UTC | |
|
Re: Resetting Internal Loop Pointers
by GrandFather (Saint) on Nov 29, 2007 at 00:18 UTC |