my $doc = $AllDocuments->GetFirstDocument; while ( $doc ) { ... $doc = $AllDocuments->GetNextDocument( $doc ); }