http://www.perlmonks.org?node_id=136120


in reply to do/redo or for(;;): what's Kosher?

I primarily do Perl / SQL integration for a living, so I am partial to the while loop with an occasional redo. A lot of my programs require a "belt and suspenders" approach to data integrity, so I will often test for previous existance of a row or foreign key relationships before doing insert, update, or deletes.

For example, occasionally, a program will receive data from someplace else and conclude that an update needs to be done. However, the database does not contain the row in question. In that case, we change some aspect of the data so that an insert will take place, and perform a redo. This is by far the most intuitive way to perform a task like this.

OTOH, I don't like the "eternal-block" construct that you describe very much, unless you label the block and put in extensive comments. Maybe I'm too focused on my typical application, but I don't see very many benefits to doing this.

Dave Aiello
Chatham Township Data Corporation