Data::RoundRobin - Serve data in a round robin manner.
my @array = qw(a b); # OO Interface my $rr = Data::RoundRobin->new(@array); print $rr->next; # a print $rr->next; # b print $rr->next; # a print $rr->next; # b ... # Infinite Loop while(my $elem = $rr->next) { ... } # Operator overloading my $rr = Data::RoundRobin->new(qw(a b)); print $rr; # a print $rr; # b print $rr; # a
This module provides a round roubin object implementation. It is similar to an iterator, only the internal counter is reset to the begining whenever it reaches the end. It might also be considered as a circular iterator.
Constructor, a list should be given to construct a Data::RoundRobin object.
Data::RoundRobin
Retrieve next value of this instance.
Retrieve next numerifed value of this instance. Invoked by Perl's operator overloadding mechanism.
Copyright 2006 by Kang-min Liu <gugod@gugod.org>
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See <http://www.perl.com/perl/misc/Artistic.html>
To install Data::RoundRobin, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::RoundRobin
CPAN shell
perl -MCPAN -e shell install Data::RoundRobin
For more information on module installation, please visit the detailed CPAN module installation guide.