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

**URL:** <https://community.unix.com/t/hash-within-array-within-hash-within-array/163169>\
**Category:** Shell Programming and Scripting\
**Created:** [July 10, 2006, 4:14pm UTC](https://community.unix.com/t/hash-within-array-within-hash-within-array/163169 "2006-07-10T16:14:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsmoriss](https://community.unix.com/user_avatar/community.unix.com/jsmoriss/32/3393_2.png) [@jsmoriss](https://community.unix.com/u/jsmoriss)\
**Post date:** [July 10, 2006, 4:14pm UTC](https://community.unix.com/t/hash-within-array-within-hash-within-array/163169/1 "2006-07-10T16:14:58Z")

</div>

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

```nohighlight
@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. 🙂 Can anyone see where I'm going wrong? The idea, of course, is to be able to get those 'name' key values... 🙂

Thanks,  
js.

---

<div class="post-metadata">

**Author:** ![cbkihong](https://community.unix.com/letter_avatar/cbkihong/32/6_449c533f586939b6e5f246632a46421f.png) [@cbkihong](https://community.unix.com/u/cbkihong)\
**Post date:** [July 10, 2006, 9:26pm UTC](https://community.unix.com/t/hash-within-array-within-hash-within-array/163169/2 "2006-07-10T21:26:34Z")

</div>

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.

```nohighlight
@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

```
