in reply to Re^2: Why are Hash keys different for the same hash? Confusing. (VCD)
in thread Why are Hash keys different for the same hash? Confusing.

Your code is very difficult to read. Using standard four spaces for indentation would help.

Each of those debug loops happens within a different conditional clause, so (without deciphering the function of your program) it would not be surprising if the data within the hash were different in each case.

As someone else mentioned, you can use sort to print out your hash in the same order each time; makes it easier to see what's going on.

You can also use Data::Dumper to save yourself a lot of boilerplate debugging code.

(Data::Dumper is part of core Perl, so your overlords should be okay with it. On the other hand, I would seriously reconsider my participation if my boss told me to do a project in Perl without CPAN -- that's just silly.)

The way forward always starts with a minimal test.
  • Comment on Re^3: Why are Hash keys different for the same hash? Confusing. (VCD)