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}]);
01 February 2009
Perl: Appending array in a hash element
Posted by
PepesmithFan
at
3:35 PM
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment