![]() |
creating a datastructure from lists
I need to convert the following lists:
house,doors,knobs,style house,doors,knobs,color house,windows,length house,windows,width into a datastructure like this; $ds = { 'house' => { 'doors' => { 'knobs' => { 'style' => "", 'color' => '"" } }, 'windows' => { 'length' => "", 'width' => "" } } }; Does this require the use of recursive calls? Thanks in advance. |
Re: creating a datastructure from lists
sal.x.lopez@gmail.com wrote: > I need to convert the following lists: > > house,doors,knobs,style > house,doors,knobs,color > house,windows,length > house,windows,width > > into a datastructure like this; > > $ds = { > 'house' => { > 'doors' => { > 'knobs' => { > 'style' => "", > 'color' => '"" > } > }, > 'windows' => { > 'length' => "", > 'width' => "" > } > } > }; > > Does this require the use of recursive calls? No, it does not. You can create loop that iterates over every element in the current line, each time assigning the reference you're using to the most recently created level of the structure. Once you've made an attempt, if it doesn't work the way you want, post here again, including a SHORT but COMPLETE script that demonstrates your error, and someone can probably help you to fix it. Paul Lalli |
Re: creating a datastructure from lists
sal.x.lopez@gmail.com wrote:
> I need to convert the following lists: > > house,doors,knobs,style > house,doors,knobs,color > house,windows,length > house,windows,width > > into a datastructure like this; > > $ds = { > 'house' => { > 'doors' => { > 'knobs' => { > 'style' => "", > 'color' => '"" > } > }, > 'windows' => { > 'length' => "", > 'width' => "" > } > } > }; > > Does this require the use of recursive calls? Thanks in advance. See this thread posted a few days ago: http://groups.google.com/group/comp....d0263039cab4bf John -- use Perl; program fulfillment |
| All times are GMT. The time now is 10:52 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.