This solution in creating its $value_key assumes that the values of the hash ("values" function) will be returned in the same order with respect to the key names for each of the different student records. I don't think that Perl guarantees that behavior.