[Petal] Does Petal support a simple while loop?

Grant McLean grant at mclean.net.nz
Tue Jun 24 23:27:07 BST 2003


Jean-Michel Hiver wrote:
 > The question about cursors has already been raised by Mark Holland,
 > and I have already provided an answer that kinda works on the list:
 >
 > http://www.email-lists.org/pipermail/petal/2003-February/000301.html
 >
 > Basically you can turn your cursor into a tied array and then use the
 > tied array with a normal 'repeat' statement.

Yes, those are approaches to the specific issue of iterating through
a list of values, but my specific requirement was really crying out
for nested while loops.  To restate it in Perl:

   while(my($artist) = $rs->grouped_column('artist')) {
     print_heading($artist);
     while(my($row) = $rs->next) {
       print_item($row);
     }
   }

So the call to $rs->grouped_column('artist') causes subsequent
calls to $rs->next to terminate when the value in the 'artist'
column changes.

Generic iterator support is not actually going to solve that
problem whereas a petal:while construct would.

Regards
Grant




More information about the Petal mailing list