in reply to Efficient partial deep cloning

I don't know how this compares against a string eval (probably depends on how deep the structure is), but if the path is stored as something like qw(A 2 H foo H bar A 1), then you could traverse down a path like so (untested, unthought out rough idea):
my @path = qw( A 2 H foo H bar A 1 ); my $data = [ "foo", "bar", { foo => { bar => [ 5, 6, ], }, }, ]; while ( @path ) { my $type = shift @path; my $index = shift @path; if ( $type eq 'A' ) { $data = $data->[$index]; } else { $data = $data->{$index}; } } print $data; # prints "6" (I hope)
Of course, if you want to assign to something in the path, you'd have to traverse the path up until the last item, then assign, etc. Ehh, I'm not sure if or when this might be more efficient or any better than the eval method, but there it is :-)