my $sql = "SELECT this, that, the_other FROM table WHERE foo = $bar"; my @rows; my $sth; my $ratchet_counter = 1; if ( $sth = $dbh->prepare($sql) ) { $sth->execute(); while ( @rows = $sth->fetchrow_array() ) { # Load in new values from current row. ( $this, $that, $the_other) = @rows; # Redefine button subs temporarily. local *callback_X = sub { ++$ratchet_counter; }; # User wanting next row. local *callback_Y = sub { $ratchet_counter = 0; }; # User choosing current row. $mw->waitVariable(\$ratchet_counter); # User making choice of show-next or keep-this. last if 0 == $rows_ratchet_index; # User made choice. } } else { $wgt->{'frame'}->{'entry'} = qq|Oops! $DBI::errstr!|; return (); }