I am new to perl and this thing is driving me nuts. I have a hash as below
%temp = (
a_collection => [\%first, \%second]
)
I want to get the array elements out as a string so i can use them as args in the loop. I have below code
foreach $item (@{$temp{'a_collection'}})
{
<convert to json> $item #convert each of the above hash to a json blob
<write to file> $file #write first blob to file "first.json" and so on
}
I got the convert to json part. I can print it to stdout. Now i want to write it to a file. Here the $file should have name "first" and "second". So the loop will create two files with names of the hash variables which are there in the above hash. I want the filenames to match so i can keep track of whats getting created.
Edit : The basic premise is simple. Whatever i do, be it json encoding etc, i want the hash variable names as a string. So in the array above, i can have a hash with any name \%somename, in the loop i want the actual string "somename" in a different variable. As above, i can use this string as file name that gets created . I cannot change the above hash structure. Its just there, created by someone else, i can only access it.
Thanks