I'm experienced in several programming languages, but Perl beats me /-: So I ask you people wiser than me for help.
I want to amend a Perl program (JSDoc) with new functionality. The basic task is simple: We have a deep structure and want to retrieve specific items, putting them into a new structure. The source structure looks like this (I stripped everything not relevant):
We want a flat list of ids and descriptions like this:$VAR1 = { 'classes' => [ { 'classid' => 'xmi.2', 'classdescription' => undef, 'methods' => [ { 'methoddescription' => '', 'methodid' => 'xmi.77', } ], 'attributes' => [ { 'attributedescription' => '', 'attributeid' => 'xmi.75', } ], }, { 'classid' => 'xmi.3', 'classdescription' => '', 'methods' => [ { 'methoddescription' => '', 'methodid' => 'xmi.82', } ], 'attributes' => [], } ] };
The basic flow is obvious:$descriptions = [ { 'id' => 'xmi.2', 'description' => undef, }, { 'id' => 'xmi.77', 'description' => '', }, { 'id' => 'xmi.75', 'description' => '', }, { 'id' => 'xmi.3', 'description' => '' }, { 'id' => 'xmi.82', 'description' => '', } ];
FOREACH class PUT classid, classdescription INTO descriptions FOREACH method PUT methodid, methoddescription INTO descriptions END FOREACH FOREACH attribute PUT attributeid, attributedescription INTO descriptions END FOREACH END FOREACH
I've tried this for several hours now, but I got mixed up in arrays, hashes, pseudo-hashes, etc.
Any hints are greatly appreciated.
NikoIn reply to Retrieving data from deep structure by enikao
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |