Hi monks!
I am searching for a robust module that would provide a way to iterate through an arbitrary and complex data structure. I wrote a module that does this on my own (with speed and robustness problems), however, this seems like such a common task that I'm pretty sure that there HAS to be a nice, robust CPAN or core module that would do the thing.
The module I wrote works like this:
my $iter = StructIterator->new (
struct => $my_struct,
);
while ( $iter->next ) {
my $value = $iter->yield;
my $hash_key_or_array_index = $iter->index;
my $current_depth = $iter->level;
## ...
}
Basically I am looking for the same thing, only robust (handling of circ. refs, blessed refs,...) and fast. There is the Data::Walk module, but I didn't really like it that much - it is not really an iterator (you provide a callback coderefs), and I don't like the way it iterates over hashes - it yields a value for a key and the next callback will yield the value.
Does anybody know about something that would suit my needs? I looked all over the web and all I found was the Data::Walk module.