in reply to searching nested structures

Thanks all, I can see whats going on now and I understand why it's happening but I'm still at a loss as how to avoid autovivification without breaking up the origional pattern into parts and testing them one at a time.

Roger: Because 'exists' still wont stop autovivification your solution above will still muddy the origional structure (If you Dumper($data) after searching you can see empty foo => {}'s everywhere.)

Update: For future reference I found this article(perlarchive.com) which had an example sub to get me started on testing deep structures without triggering autovivification.

Replies are listed 'Best First'.
Re: Re: searching nested structures
by pg (Canon) on Jan 05, 2004 at 05:18 UTC

    Unfortunately, you have to control this yourself.

    To avoid unwanted autovivification, before read/test an element, always first make sure the existance of all its ancestors. That "all" in bold is automatically guranteed, if your checking is start from the oldest ancestor, and stops at the first sight of a non-exist ancestor.