Good thought! I tried putting
$imap->select( $imap_folder ) or die "IMAP Select Error for imap folder [$imap_folder]: $@"; inside the while loop, and still got no joy.
They laughed at Joan of Arc, but she went right ahead and built it. --Gracie Allen