in reply to Foreach Problem! Help!!!

you need to sort the keys first otherwise it will be random as noted here Basically for my $var (sort keys %hash) { ... }