Hi Anonymous,
It would help if you could show what the input data $names and $claim looks like (with Data::Dumper or Data::Dump; you normally don't need both) and what you expect the output data to look like. At the moment, I have to guess whether you want the values of the %data hash to be array references (a "hash of arrays"), or if you want an "array of hashes" (the latter would make more sense to me). See also Short, Self Contained, Correct Example and How do I post a question effectively?
You're using Data::Dumper to output the string after it's been encoded to JSON. To help in debugging, you could also dump %data to see what the Perl data structure you've created looks like. See also the Basic debugging checklist.
Note that push only applies to pushing values onto arrays. To add a value to a hash after it's been created, you simply assign to the key: $hash{$key} = $value;.
I'm guessing you might want an array of hashes. How to generate and work with them, as well as other data structures, is described in perldsc. The pages perlreftut and perlref will also be very helpful.
Hope this helps,
-- Hauke D
In reply to Re: Push values into a hash
by haukex
in thread Push values into a hash
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |