Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
How to Map a scalar to a key that is an array?by symgryph (Sexton) |
on Jul 31, 2019 at 21:28 UTC ( [id://11103671]=perlquestion: print w/replies, xml ) | Need Help?? |
symgryph has asked for the wisdom of the Perl Monks concerning the following question:
I have some data that looks like this:
I would like to create a hashmap so I can count the # of items under each of the 'arn' so the key would be arn:aws:iam::11111111111:role/ADFS-MyRoleName and the values would be everything until the 'blank line' which is the end of record marker. I had thought of using split, but am unsure on how to get the 1:many relationship going. I suspect I need to somehow use a for loop and iterate through each 'arn' value, see what happens between them, and then create a map from that. The only problem is I have no idea how to do this. I looked at data:dumper but this always assumes 1:1 relationships afaik. I couldn't grok it. Could anyone suggest a code snippet that will at least create the datastructure? I can do the rest, but I really am not good at datastructures.
"Two Wheels good, Four wheels bad."
Back to
Seekers of Perl Wisdom
|
|