http://www.perlmonks.org?node_id=261011


in reply to A Quote
in thread Object to Map Multiple Values to a Single Key

The object was never meant to be a replacement for hashes

That was (as I read it) Abigail's point. You're not providing a front end to a hash, you're providing an easy way of doing key -> arrayref mappings. You're dealing with a hashref not a hash. Hence your module description could be better expressed.

I think you read way to much into Abigail's post. Abigail's (usually pretty darn accurate) comments may be blunt, but the bluntness is always aimed at code, not people.

Unlike your message, which I --'d since I find it too close to a personal attack for my tastes.

The object is trivial. Nothing wrong with that in itself. However we have an expressive syntax in Perl already for this sort of thing.

my %map; push @{$map{K1}}, 'V1'; push @{$map{K1}}, 'V2'; push @{$map{K2}}, 'V3'; push @{$map{K3}}, 'V4'; print Dumper(\%map); # or my %map2; $map2{K1} = ['V1', 'V2']; $map2{K2} = ['V3']; $map2{K3} = ['V4']; print Dumper(\%map2); # or my %map3; @map3{'K1','K2','K3'} = (['V1', 'V2'], ['V3'], ['V4']); print Dumper(\%map3); # etc.

So, for me, it doesn't really supply anything that Perl doesn't give us already for free.

On a stylistic note I would use add_value() (or similar) rather than put() since the latter sounds like it should be the inverse of get() and it isn't.