in reply to HwithinHoA? Complex Data Structure...I am so lost...
You still haven't added
to the top of your code. If you had you would have seen that it is still throwing errors.use strict;
Declaring all your variables fixes most of them. There was a syntax snag (not exactly an error)
As to the question at the end of the script.#@internal_array_ref[1] = 20; # better as $internal_array_ref[1] = 20;
I want to be able to have a code that is flexible. So that I can change the number of internal_hash_number and the code will be smart enough to name the array based on what it is called in the hash.In the hash you are looking at you have primary and secondary keys. Each secondary key points to an array ref. You can iterate over it by
output:for my $key_primary (keys %internal_hash_ref) { print qq{primary key: *$key_primary*\n}; for my $key_secondary (keys %{$internal_hash_ref{$key_primary}}){ print qq{\tsecondary key: *$key_secondary*\n}; print qq{\t\t*@{$internal_hash_ref{$key_primary}{$key_secondary}}* +\n}; } }
So, @{$internal_hash_ref{$key_primary}{$key_secondary}} is the name of the array. If this isn't what you want you will have to explain a bit more what it is you want to do with this "named" array.primary key: *1* secondary key: *1_b* *34 33 49 32 46 47 27 31 46 30* secondary key: *1_a* *44 20 20 32 32 47 39 35 24 41* primary key: *2* secondary key: *2_a* *34 23 24 30 10 38 47 23 17 25* secondary key: *2_b* *45 47 44 44 45 39 13 35 14 23*
Don't overwrite your posts and use strict and warnings.
Good luck!
|
|---|