|Don't ask to ask, just ask|
Re^6: excel to hashby 1nickt (Monsignor)
|on Sep 13, 2017 at 21:19 UTC||Need Help??|
Work from the inside.
Let's start again. Say you have a hash reference $excel_href. (Note you should name it with 'href' since it is not a hash, but a scalar that holds a reference to the hash.) Now you want to loop through the keys, so make it easy on yourself and deference the hashref at the start.
Loop through the keys, using for, which is the same as for each:
So now you have the key, and you need the value, and we know that the value is going to be a "sub-hash", ie a scalar holding a reference to another hash. Since we're lazy and we don;t like typing arrows, and for consistency, we can dereference this hashref, too, and we'll do it right after we fetch the value:
Finally, you want to get the value of the key named 'Name' in the inner hash.
Or, for a version more similar to yours:
Or, for a version sticking to simple for loops (each should be handled with care):
Or, for the convenient way using map (assuming you know the name of the inner key you are trying to read):
I expect all this is clear as mud at first reading, but have a play around and it should start making sense. Post back here with any questions.
The way forward always starts with a minimal test.