Perl:
Can anyone tell me why after I convert the hash into an array, when I print it out, it's not in the order like the hash? See below..
my %cityZip = ("Logan, AL", 35098,
"Los Angeles, CA", 90001,
"OrangeVille, IL", 61060,
"Palm Bay, FL", 32905,
"Smithville, GA", 31787,
"Haiku, HI", 96708,
"Calder, ID", 83808,
"Sioux City, IA", 51101,
"Lexington, KY", 40502,
"New Orleans, LA", 70129,
"Newburg, MD", 20664,
"Brooklyn, NY", 11230,
"Las Vegas, NV", 89101,
"Charlotte, NC", 28202,
"Columbus, OH", 43222,
"Garden City, SD", 57236,
"Houston, TX", 77002,
"Paragonah, UT", 84760,
"Rockport, WA", 98283,
"Newcastle, WY", 82701);
my @zipCode = %cityZip;
my $arraySize = @zipCode;
my $i;
for ($i = 0; $i < $arraySize; $i+=2) {
print "$zipCode[$i] = $zipCode[$i+1] \n";
}
And the output I got was...
Logan, AL = 35098
Palm Bay, FL = 32905
New Orleans, LA = 70129
Smithville, GA = 31787
Houston, TX = 77002
Garden City, SD = 57236
Rockport, WA = 98283
Charlotte, NC = 28202
Los Angeles, CA = 90001
Columbus, OH = 43222
Newcastle, WY = 82701
Haiku, HI = 96708
Las Vegas, NV = 89101
Lexington, KY = 40502
Newburg, MD = 20664
OrangeVille, IL = 61060
Sioux City, IA = 51101
Paragonah, UT = 84760
Calder, ID = 83808
Brooklyn, NY = 11230