in reply to Style and Preference on Loops

If you work with DBI, using a while-loop may be more efficient than reading the entire result set into memory and iterating over it using a for loop. See $sth->bind_columns() and the last paragraph in $sth->fetchall_arrayref(): A standard while loop with column binding is often faster because the cost of allocating memory for the batch of rows is greater than the saving by reducing method calls. It's possible that the DBI may provide a way to reuse the memory of a previous batch in future, which would then shift the balance back towards fetchall_arrayref().

Try Devel::NYTProf to find out if that difference is really relevant for your application. Note that NYTProf will very likely show you the real bottlenecks in your application.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)