|XP is just a number|
Looping Over Hash Skips an Element?by mmartin (Monk)
|on Jan 06, 2012 at 17:44 UTC||Need Help??|
mmartin has asked for the
wisdom of the Perl Monks concerning the following question:
I'm looping through a hash that has about 240 elements. The order of the hash defiantly matters, so I used "use Tie::IxHash;" to preserve the ordering of the hash.
So in the code below, I loop through the hash and have a counter that is set to 1 and resets when its > 8.
But for some reason it skips what should be the 9th element in the hash on each reset.
The code below contains only a small portion of the hash (the first 32 elements).
And when I execute the code it prints the following:
Gi3/1 Gi3/2 Gi3/3 Gi3/4 Gi3/5 Gi3/6 Gi3/7 Gi3/8
Gi3/10 Gi3/11 Gi3/12 Gi3/13 Gi3/14 Gi3/15 Gi3/16 Gi3/17
Gi3/19 Gi3/20 Gi3/21 Gi3/22 Gi3/23 Gi3/24 Gi3/25 Gi3/26
Gi3/28 Gi3/29 Gi3/30 Gi3/31 Gi3/32
As you can see it skips would would be the 9th element, going from Gi3/8 to Gi3/10 and so on...
I'm assuming it's somehting to do with my logic. Anyone know what I'm doing wrong?
Any thoughts would be much appreciated.