wpahiker has asked for the wisdom of the Perl Monks concerning the following question:
And the code is pretty straight-forward:00601PR787ADJUNTAS 00602PR787AGUADA 00603PR787AGUADILLA 00604PR787AGUADILLA 00605PR787AGUADILLA 00606PR787MARICAO 00610PR787ANASCO 00611PR787ANGELES 00612PR787ARECIBO 00613PR787ARECIBO
When the "foreach" loop runs I get 20 records listed instead of 10:$count = 0; open (ZIPCODE, "<../Files/ZipCodes.txt") or die "Cannot open ZipCode: +$1\n"; while (<ZIPCODE>) { chomp; ($Zip) = substr($_,0,5); ($State) = substr($_,5,2); ($AreaCode) = substr($_,7,3); ($City) = substr($_,10); $ZipDB{$Zip} = "$City|$State|$AreaCode"; $count++; } print "\nStored: $count\n"; $count = 0; foreach $Zip (%ZipDB) { print "$Zip = [$ZipDB{$Zip}]\n"; $count++; } close (ZIPCODE); print "\n$count Zip codes found\n";
I am at a total loss as to why this is not working. MikeStored: 10 00611 = [ANGELES|PR|787] ANGELES|PR|787 = [] 00612 = [ARECIBO|PR|787] ARECIBO|PR|787 = [] 00603 = [AGUADILLA|PR|787] AGUADILLA|PR|787 = [] 00610 = [ANASCO|PR|787] ANASCO|PR|787 = [] 00606 = [MARICAO|PR|787] MARICAO|PR|787 = [] 00601 = [ADJUNTAS|PR|787] ADJUNTAS|PR|787 = [] 00602 = [AGUADA|PR|787] AGUADA|PR|787 = [] 00605 = [AGUADILLA|PR|787] AGUADILLA|PR|787 = [] 00613 = [ARECIBO|PR|787] ARECIBO|PR|787 = [] 00604 = [AGUADILLA|PR|787] AGUADILLA|PR|787 = [] 20 Zip codes found
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Odd hash problem
by vagnerr (Prior) on Feb 23, 2007 at 15:02 UTC | |
by wpahiker (Acolyte) on Feb 23, 2007 at 15:11 UTC | |
Re: Odd hash problem
by johngg (Canon) on Feb 23, 2007 at 15:55 UTC | |
Re: Odd hash problem
by imp (Priest) on Feb 23, 2007 at 15:16 UTC | |
Re: Odd hash problem
by Fletch (Bishop) on Feb 23, 2007 at 15:02 UTC | |
by wpahiker (Acolyte) on Feb 23, 2007 at 15:51 UTC | |
by imp (Priest) on Feb 23, 2007 at 16:05 UTC | |
by johngg (Canon) on Feb 23, 2007 at 20:41 UTC | |
by Fletch (Bishop) on Feb 23, 2007 at 15:57 UTC |