User:AnomieBOT/source/AnomieBOT/API/Iterator.pm/doc

NAME edit

AnomieBOT::API::Iterator - AnomieBOT API iterator class

SYNOPSIS edit

 use AnomieBOT::API;
 
 my $api = AnomieBOT::API->new('/path/to/config_file', 1);
 $api->login();
 my $iter = $api->iterator(list=>'allpages', apnamespace=>0, aplimit=>10);
 while(my $res = $iter->next){
     # Do stuff
 }

DESCRIPTION edit

AnomieBOT::API is a class implementing various functions needed by a MediaWiki bot. This class represents an iterator over a result set.

METHODS edit

$iter->cur
This returns the current result page, or undef if there is no current result.
Note that no API query is done on creation, and thus no result object is current. $iter->next must be called at least once before this function is useful.
$iter->next
This moves the pointer to the next result and returns it, performing API queries as necessary.
The return object is normally a hashref representing one page object, with an additional property _ok_ set to a true value. If _ok_ is false, the returned hashref is instead the error object as returned by $api->query(). Calling $iter->next again after an error will retry the API query, which may or may not succeed.
When no more results are available, undef is returned.

COPYRIGHT edit

Copyright 2008–2013 Anomie

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.