About This Journal
Technical concerns tend to find a solution as long as there are good people working on them. And Linux has the very best. - Linus Torvalds
Perl: Appending array in a hash element
pepesmith
My code :
push($parentmenu{$parentkey}{childlist},[$childmenu{$childid}{name},$childmenu{$childid}{link}]);
Gives me this error.
Type of arg 1 to push must be array (not hash element) at ./test.cgi line 34, near “])”
Execution of ./test.cgi aborted due to compilation errors.
And it was just resolved by adding the @ and enclose it with {} – see the code below. I need an explanation though, but I’ll have to find the explanation later, for the meantime the solution just worked for my task.
push(@{$parentmenu{$parentkey}{childlist}},[$childmenu{$childid}{name},$childmenu{$childid}{link}]);
Posted in Miscellaneous |
No Comments »
Leave a Comment