Hash within array, within hash, within array...

I have a little problem. To keep a configuration simple, I've exceeded my perl knowledge. :slight_smile: I've worked with multi-dimentional arrays before, but this one has me beat:

@info = (
    {
        'defval' => 'abc'
        'stats' = (
            { 'name' => 'a', },
            { 'name' => 'b', },
        ),
    },
    {
        'defval' => 'def'
        'stats' = (
            { 'name' => 'd', },
            { 'name' => 'e', },
        ),
    },
);

my @infolist = $info[0]->{stats};    # I have a feeling this is where I'm going wrong...

print $infolist[0]->{name};    # <-- works!
print $infolist[1]->{name};    # <-- does not!

Like I said, I've exceeded my perl knowledge. :slight_smile: Can anyone see where I'm going wrong? The idea, of course, is to be able to get those 'name' key values... :slight_smile:

Thanks,
js.

I have no idea why you said one of the statements worked, because your entire snippet was full of errors, and I confirmed that by running on my machine with compilation errors.

Not sure whether my modified version is what you intended.

@info = (
    {
        'defval' => 'abc',
        'stats' => [
            { 'name' => 'a', },
            { 'name' => 'b', },
        ],
    },
    {
        'defval' => 'def',
        'stats' => [
            { 'name' => 'd', },
            { 'name' => 'e', },
        ],
    },
);

my $r_infolist = $info[0]->{stats}; 

print $r_infolist->[0]{name};    # <-- a
print $r_infolist->[1]{name};    # <-- b