in reply to Re: inverting keys in a 2-D Hash
in thread inverting keys in a 2-D Hash
Can’t say that I agree with you on this one: there’s really no compelling requirement to attempt to modify the structure “in place,” and plenty of good reasons not to . . .
Especially when we consider that “what the hashref-of-hashrefs actually contains is ...” arrayrefs. We aren’t copying any arrays: what we’re actually doing is creating a second (inverted ...) hashref-of-hashrefs structure, which contains references to ... the same arrays that the “old” one refers-to. (And we are, thereafter, entirely free to keep both of these hashrefs-of-hashrefs, without penalty, since they are both effectively just “indexes” to a single collection of anonymous-arrays.)