Iterators are a nice way to perform operations on large datasets without having to keep all of the data you're working on in memory at the same time. Most people have experience with iterators already from working with filehandles. They are basically iterators hidden behind a somewhat odd syntax. This module gives you the same way of executing database queries.

The trivial example at the start of the synopsis is not very different from using "fetchrow_hashref" in DBI directly to retrieve your database rows. But when we look at the second example we can start to see how it allows much cleaner separation of concerns without having to modify the core class (Person) to support iterators or database interaction at all.

For more information about iterators and how they can work for you, have a look at chapter 4 in the book Higher-Order Perl mentioned below. It is free to download and highly recommended.

Executes the query with the optional placeholder values. Returns a code reference you can execute until it is exhausted. If called in list context, it will also return a reference to the statement object itself. The iterator returns exactly what "fetchrow_hashref" in DBI returns. When the iterator is exhausted it will return undef.

The code is open to the world, and available for you to hack on. Please feel free to browse it and play with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull from your repository :)