The other replies already have covered where the error is in your code, as well as some style advice (arrow operator and such), so I won't repeat any of that. But I think you might want to check
References quick reference by
tye, it will help you understand the relationship between $$foo{$bar}, $foo->{$bar}, ${$foo}{$bar}... (I know it helped me ;)
hope this helps,