The modular approach calls for a build_hash sub, which gets called with parameters (twice) to build each hash, and return a reference to that. if you programmed this in OO style, it would be similar to the modular -- divide and conquer -- approach.
The other way is to return a reference to an anonymous hash/array of hashes. just a little different to dereference then.