in reply to searching nested structures
Given an expression that specifies a hash element or array ele- ment, returns true if the specified element in the hash or array has ever been initialized, even if the corresponding value is undefined. The element is not autovivified if it doesn't exist.
You are autovifying.
Your eval is creating the a-formentioned structure. You may wanna break down your search structure in a different way.. . . print "----\n"; print Dumper $data; my $ref = qq|\$data->{$k}$path|; print "String: $ref\n"; if (my $val = eval($ref)) { push @results, ref($val) ? $val : eval "\\$ref"; } if (exists $data->{$k}) { print Dumper $data; push @results, rec_data($path, $data->{$k}); . . .
$VAR1 = { 'foo' => { 'baz' => 'baz', 'bar' => 'bar' }, 'bar' => { 'baz' => 'baz' } }; String: $data->{foo}->{foo}->{bar} $VAR1 = { 'foo' => { 'foo' => {}, 'baz' => 'baz', 'bar' => 'bar' }, 'bar' => { 'baz' => 'baz' } };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: searching nested structures
by pg (Canon) on Jan 05, 2004 at 05:05 UTC |