in reply to Resetting Internal Loop Pointers
You need to reset the each iterator. Using keys does that. Refactoring your code a little may help see what's going on. Consider:
use strict; while (my ($defNet, $defKey) = each (%defMaskArray)) { ... HOST: for (my $bCount = 1; $bCount <= $hostsN; $bCount++) { ... while (my ($n, $host) = each %$refHandle) { ... my $testResult = test ($bCount, $boundary, $host, $defNet, $de +fKey, \@routeArray); keys %$refHandle if $testResult ne 'ok'; # Reset each redo HOST if $testResult eq 'retry'; next HOST if $testResult eq 'greater'; } ... } } sub test { my ($bCount, $boundary, $host, $defNet, $defKey, $routeArray, ) = +@_; for (my $iCount = 0; $iCount <= 256; $iCount = ($iCount + $boundar +y)) { # evaluate boundaries if ($iCount == $host || (($iCount + $boundary) - 1) == $host) +{ print OUT "$defNet for $host fell on a boundary for mask - $boun +dary\n"; if ($boundary == 256) { ... } else { ... return 'retry'; } } elsif ($iCount > $host) { ... return 'greater'; } else { ... } } return 'ok'; }
Note too that you should use strictures (use strict; use warnings;) and generally avoid using $a and $b except for their magical use in the context of sort.
|
|---|