GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  LIST::CYCLE (3)

.ds Aq ’

NAME

List::Cycle - Objects for cycling through a list of values

CONTENTS

VERSION

Version 1.02

SYNOPSIS

List::Cycle gives you an iterator object for cycling through a series of values. The canonical use is for cycling through a list of colors for alternating bands of color on a report.



    use List::Cycle;

    my $colors = List::Cycle->new( {values => [#000000, #FAFAFA, #BADDAD]} );
    print $colors->next; # #000000
    print $colors->next; # #FAFAFA
    print $colors->next; # #BADDAD
    print $colors->next; # #000000
    print $colors->next; # #FAFAFA
    ... etc ...



You’d call it at the top of a loop:



    while ( ... ) {
        my $color = $colors->next;
        print qq{<tr bgcolor="$color">;
        ...
    }



Note that a List::Cycle object is not a standard Perl blessed hash. It’s an inside-out object, as suggested in Perl Best Practices. In the seven years since PBP has come out, inside-out objects have been almost universally ignored, but I keep List::Cycle as an example. If you don’t care about the internals of the object, then List::Cycle is a fine module for you to use.

FUNCTIONS

    new( {values => \@values} )

Creates a new cycle object, using @values.

The values keyword can be vals, if you like.

CW$cycle->set_values(\@values)

Sets the cycle values and resets the internal pointer.

CW$cycle->reset

Sets the internal pointer back to the beginning of the cycle.



    my $color = List::Cycle->new( {values => [qw(red white blue)]} );
    print $color->next; # red
    print $color->next; # white
    $color->reset;
    print $color->next; # red, not blue



CW$cycle->dump

Returns a handy string representation of internals.

CW$cycle->next

Gives the next value in the sequence.

AUTHOR

Andy Lester, <andy at petdance.com>

SUPPORT

You can find documentation for this module with the perldoc command.



    perldoc List::Cycle



You can also look for information at:
o AnnoCPAN: Annotated CPAN documentation

<http://annocpan.org/dist/List-Cycle>

o CPAN Ratings

<http://cpanratings.perl.org/d/List-Cycle>

o RT: CPAN’s request tracker

<http://rt.cpan.org/NoAuth/Bugs.html?Dist=List-Cycle>

o Search CPAN

<http://search.cpan.org/dist/List-Cycle>

o Source code repository

<http://github.com/petdance/list-cycle>

BUGS

Please report any bugs or feature requests to bug-list-cycle @ rt.cpan.org, or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=List-Cycle>. I will be notified, and then you’ll automatically be notified of progress on your bug as I make changes.

ACKNOWLEDGEMENTS

List::Cycle is a playground that uses some of the ideas in Damian Conway’s marvelous Perl Best Practices. <http://www.oreilly.com/catalog/perlbp/> One of the chapters mentions a mythical List::Cycle module, so I made it real.

Thanks also to Ricardo SIGNES and Todd Rinaldo for patches.

COPYRIGHT & LICENSE

Copyright 2005-2012 Andy Lester.

This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License v2.0.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 CYCLE (3) 2012-12-24

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.