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


in reply to Complex Data Structure Suggestions Wanted

Here are a couple more alternatives...
sub ReadSource{ my ($DataSource, $HashRef) = @_; my @Data = get_data(); for (@Data){ my $item = $HashRef->{$_} ||= []; push( @$item, $DataSource ); } }
..or..
sub ReadSource{ my ($DataSource, $HashRef) = @_; my @Data = get_data(); push( @{ $HashRef->{$_} ||= [] }, $DataSource ) for @Data; }
There really is more than one way to do it!