I want to dynamically create a structure as follows:
{
edition1 => {
Jim => ["title1", "title2"],
John => ["title3", "title4"],
},
edition2 => {
Jim => ["titleX",],
John => ["titleY,],
} etc
}
I am confused on how I do it.
Basically I am thinking in the terms of:
my $edition = "edition1";
my $author = "Jim";
my $title = "title1";
my %main_hash = ();
${$main_hash{$edition}} ||= {};
${$main_hash{$edition}}->{$author} ||= [];
push @{{$main_hash{$edition}}->{$author}} , $title;
But somehow I am not sure how I can do it properly and the syntax seems very complex.
How can I achieve what I want in a nice/clear manner?