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


in reply to Complex Data Structure Suggestions Wanted

You don't have to check for existence. You can just use an undefined value as an arrayref and it will autovivify:
foreach my $ItemID (@Data){ push @{$$HashRef{$ItemID}}, $DataSource; # The usual preferred notation is # push @{$HashRef->{$ItemID}}, $DataSource; }

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: Complex Data Structure Suggestions Wanted
by Ninthwave (Chaplain) on Jun 07, 2005 at 12:19 UTC

    Thank you, I prefer the preferred notation nice to agree with the masses for a change.

    "No matter where you go, there you are." BB