in reply to having a hash maintain order when passed to a sub

You are not passing a hash to the sub. You flatten the hash to a list, pass that list, and build a new hash in the sub.

Either make the new hash also a tied hash, or pass a reference to the hash. The latter is more efficient, but if you change the hash inside the sub, the outer hash (which is the same) is changed as well.

  • Comment on Re: having a hash maintain order when passed to a sub