Perl’s Data::Rmap allows you to recursively evaluate a BLOCK over a list of data structures (locally setting $_ to each element) and return the list composed of the results of such evaluations. $_ can be used to modify the elements.
This is useful for iterating over things like nested hashes, or hierarchies of arrays of hashes and the like.
Ruby’s
Enumerabledoes everything you want, I think. ‘… and return the list composed of the results of such evaluations’ indicates you wantEnumerable#map. My first go would be something like this: