What if you have a hash of some hashes of some arrays and you'd like to print the content grouped, mostly based on the contents of the arrays? You cannot simply traverse the data structure and print as the grouping must be done based on some internal part of the data structure.

You first will have to go throughout all the data, built a new data structure and then you can go over that data structure and print it.

This new data structure can contain the original data in some other hierarchy, or it can contain some already partially formatted data.

The former will probably allow for more reuse - in case that is needed. The latter will be probably simpler to write and easer to understand.