Tie-Cycle-1.221/000755 000765 000024 00000000000 12654216432 013540 5ustar00brianstaff000000 000000 Tie-Cycle-1.221/Changes000644 000765 000024 00000004213 12654216422 015032 0ustar00brianstaff000000 000000 Revision history for Perl module Tie::Cycle 1.221 2016-02-02T21:17:53Z * Freshen distro 1.21 - 2014-10-03 * Update Makefile for better META data 1.20 - 2014-08-16 * Bump to user version 1.19_01 - 2013-09-02 * Take out // (5.10 feature I used without thought) to restore 5.8 compatibility. 1.19 - 2013-08-27 * Update for modern usage, better code * I use this as an example in Mastering Perl, so I shouldn't leave embarrassing practices in the code. :) 1.17 - 2009-01-30 * Updated the docs for the move to Github * There aren't any code changes 1.16 - 2007-10-27 * distro cleanups after moving from CVS to SVN 1.15 - 2007-03-18 * Cleaning dist for new SVN repository * No need to upgrade 1.14 - 2007-01-09 * updated copyright and license info * no code changes, so no need to upgrade 1.13 - 2006-05-17 * Minor cleanups in docs, copyright, and pod testing. No need to upgrade. 1.12 - 2005-03-08 * Added POD coverage tests. No need to upgrade 1.11 - 2005-01-03 * Previously, this module refused to work unless the input array had more than one element. What's the point of cycling otherwise? I've removed that restriction, though, because I shouldn't be the one who gets to decide that. A one element array should get a chance to act like any other array. It just happens to have one element. 1.09 - 2004-09-02 * Just some distribution fixes. No need to upgrade. 1.07 - 2004-01-31 * No code changes. * Removed dependencies on Test::Manifest, Test::Pod and File::Find::Rule. * Fixed some warnings in tests. 1.06 - 2002-12-17 * cycle.t test was actually one from Tie::Toggle. it is not the right test. 1.05 - 2002-12-17 * removed 'require 5.6.0' (perl5.8 complains about v-strings) * beefed up distribution files * no code changes --- no need to install if you already have this 0.05 - 2002-08-14 * added reset() method for underlying object so Andy Lester can do HTML table tricks * since I was there, I added previous() and next() methods so you can peek at values without affecting the position. 0.02 - 2001-01-24 * minor doc fixes 0.01 - 2000-08-12 * original version; created by h2xs 1.20 with options -AXn Tie::Cycle Tie-Cycle-1.221/examples/000755 000765 000024 00000000000 12654216426 015361 5ustar00brianstaff000000 000000 Tie-Cycle-1.221/INSTALL.SKIP000644 000765 000024 00000000156 12654216422 015337 0ustar00brianstaff000000 000000 README\.pod README.* # things that might be in local directories after fooling # around with them \.DS_Store Tie-Cycle-1.221/lib/000755 000765 000024 00000000000 12654216426 014311 5ustar00brianstaff000000 000000 Tie-Cycle-1.221/LICENSE000644 000765 000024 00000017401 12654216422 014547 0ustar00brianstaff000000 000000 The Tie::Cycle module is licensed under the same terms as perl itself, under the Artistic License 2.0. Artistic License 2.0 Copyright (c) 2000-2006, The Perl Foundation. http://www.perlfoundation.org/artistic_license_2_0 Preamble This license establishes the terms under which a given free software Package may be copied, modified, distributed, and/or redistributed. The intent is that the Copyright Holder maintains some artistic control over the development of that Package while still keeping the Package available as open source and free software. You are always permitted to make arrangements wholly outside of this license directly with the Copyright Holder of a given Package. If the terms of this license do not permit the full use that you propose to make of the Package, you should contact the Copyright Holder and seek a different licensing arrangement. Definitions "Copyright Holder" means the individual(s) or organization(s) named in the copyright notice for the entire Package. "Contributor" means any party that has contributed code or other material to the Package, in accordance with the Copyright Holder's procedures. "You" and "your" means any person who would like to copy, distribute, or modify the Package. "Package" means the collection of files distributed by the Copyright Holder, and derivatives of that collection and/or of those files. A given Package may consist of either the Standard Version, or a Modified Version. "Distribute" means providing a copy of the Package or making it accessible to anyone else, or in the case of a company or organization, to others outside of your company or organization. "Distributor Fee" means any fee that you charge for Distributing this Package or providing support for this Package to another party. It does not mean licensing fees. "Standard Version" refers to the Package if it has not been modified, or has been modified only in ways explicitly requested by the Copyright Holder. "Modified Version" means the Package, if it has been changed, and such changes were not explicitly requested by the Copyright Holder. "Original License" means this Artistic License as Distributed with the Standard Version of the Package, in its current version or as it may be modified by The Perl Foundation in the future. "Source" form means the source code, documentation source, and configuration files for the Package. "Compiled" form means the compiled bytecode, object code, binary, or any other form resulting from mechanical transformation or translation of the Source form. Permission for Use and Modification Without Distribution (1) You are permitted to use the Standard Version and create and use Modified Versions for any purpose without restriction, provided that you do not Distribute the Modified Version. Permissions for Redistribution of the Standard Version (2) You may Distribute verbatim copies of the Source form of the Standard Version of this Package in any medium without restriction, either gratis or for a Distributor Fee, provided that you duplicate all of the original copyright notices and associated disclaimers. At your discretion, such verbatim copies may or may not include a Compiled form of the Package. (3) You may apply any bug fixes, portability changes, and other modifications made available from the Copyright Holder. The resulting Package will still be considered the Standard Version, and as such will be subject to the Original License. Distribution of Modified Versions of the Package as Source (4) You may Distribute your Modified Version as Source (either gratis or for a Distributor Fee, and with or without a Compiled form of the Modified Version) provided that you clearly document how it differs from the Standard Version, including, but not limited to, documenting any non-standard features, executables, or modules, and provided that you do at least ONE of the following: (a) make the Modified Version available to the Copyright Holder of the Standard Version, under the Original License, so that the Copyright Holder may include your modifications in the Standard Version. (b) ensure that installation of your Modified Version does not prevent the user installing or running the Standard Version. In addition, the Modified Version must bear a name that is different from the name of the Standard Version. (c) allow anyone who receives a copy of the Modified Version to make the Source form of the Modified Version available to others under (i) the Original License or (ii) a license that permits the licensee to freely copy, modify and redistribute the Modified Version using the same licensing terms that apply to the copy that the licensee received, and requires that the Source form of the Modified Version, and of any works derived from it, be made freely available in that license fees are prohibited but Distributor Fees are allowed. Distribution of Compiled Forms of the Standard Version or Modified Versions without the Source (5) You may Distribute Compiled forms of the Standard Version without the Source, provided that you include complete instructions on how to get the Source of the Standard Version. Such instructions must be valid at the time of your distribution. If these instructions, at any time while you are carrying out such distribution, become invalid, you must provide new instructions on demand or cease further distribution. If you provide valid instructions or cease distribution within thirty days after you become aware that the instructions are invalid, then you do not forfeit any of your rights under this license. (6) You may Distribute a Modified Version in Compiled form without the Source, provided that you comply with Section 4 with respect to the Source of the Modified Version. Aggregating or Linking the Package (7) You may aggregate the Package (either the Standard Version or Modified Version) with other packages and Distribute the resulting aggregation provided that you do not charge a licensing fee for the Package. Distributor Fees are permitted, and licensing fees for other components in the aggregation are permitted. The terms of this license apply to the use and Distribution of the Standard or Modified Versions as included in the aggregation. (8) You are permitted to link Modified and Standard Versions with other works, to embed the Package in a larger work of your own, or to build stand-alone binary or bytecode versions of applications that include the Package, and Distribute the result without restriction, provided the result does not expose a direct interface to the Package. Items That are Not Considered Part of a Modified Version (9) Works (including, but not limited to, modules and scripts) that merely extend or make use of the Package, do not, by themselves, cause the Package to be a Modified Version. In addition, such works are not considered parts of the Package itself, and are not subject to the terms of this license. General Provisions (10) Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license. (11) If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license. (12) This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder. (13) This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation Tie-Cycle-1.221/Makefile.PL000644 000765 000024 00000005004 12654216422 015510 0ustar00brianstaff000000 000000 package Tie::Cycle; use strict; use warnings; =encoding utf8 =head1 The build file for Tie::Cycle This build file is a modulino; it works as both a build script and a module. To build the distribution, run this file normally: % perl Makefile.PL But, it's more interesting than that. You can load it with C and call C to get the data structure it passes to C: my $package = require '/path/to/Makefile.PL'; my $arguments = $package->arguments; Note that C-ing a file makes an entry in C<%INC> for exactly that name. If you try to C another file with the same name, even from a different path, C thinks it has already loaded the file. As such, I recommend you always require the full path to the file. The return value of the C is a package name (in this case, the name of the main module. Use that to call the C method. Even if this distribution needs a higher version of Perl, this bit only needs v5.8. You can play with the data structure with a primitive Perl. =cut use File::Spec::Functions qw(catfile); my $module = __PACKAGE__; ( my $dist = $module ) =~ s/::/-/g; my $github = 'https://github.com/briandfoy/tie-cycle'; my $main_file = catfile( 'lib', split /::/, "$module.pm" ); my %WriteMakefile = ( 'MIN_PERL_VERSION' => '5.008', 'NAME' => $module, 'ABSTRACT_FROM' => $main_file, 'VERSION_FROM' => $main_file, 'LICENSE' => 'perl', 'AUTHOR' => 'brian d foy ', 'CONFIGURE_REQUIRES' => { 'ExtUtils::MakeMaker' => '6.64', 'File::Spec::Functions' => '0', }, 'BUILD_REQUIRES' => { }, 'TEST_REQUIRES' => { 'Test::More' => '0.95', }, 'PREREQ_PM' => { 'Carp' => '0', }, 'META_MERGE' => { 'meta-spec' => { version => 2 }, resources => { repository => { type => 'git', url => "$github.git", web => $github, }, bugtracker => { web => "$github/issues", }, homepage => $github, }, }, 'clean' => { FILES => "$dist-*" }, ); sub arguments { \%WriteMakefile } do_it() unless caller; sub do_it { my $MM ='ExtUtils::MakeMaker'; my $MM_version = eval{ "$MM " . $WriteMakefile{'CONFIGURE_REQUIRES'}{'ExtUtils::MakeMaker'} } || "$MM 6.64"; eval "use $MM_version; 1" or die "Could not load $MM_version: $@"; eval "use Test::Manifest 1.21"; my $arguments = arguments(); my $minimum_perl = $arguments->{MIN_PERL_VERSION} || '5.008'; eval "require $minimum_perl;" or die $@; WriteMakefile( %$arguments ); } no warnings; __PACKAGE__; Tie-Cycle-1.221/MANIFEST000644 000765 000024 00000000572 12654216432 014675 0ustar00brianstaff000000 000000 Changes examples/README INSTALL.SKIP lib/Tie/Cycle.pm LICENSE Makefile.PL MANIFEST This list of files MANIFEST.SKIP README.pod t/cycle.t t/load.t t/one.t t/pod.t t/pod_coverage.t t/test_manifest xt/changes.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Tie-Cycle-1.221/MANIFEST.SKIP000644 000765 000024 00000002005 12654216422 015432 0ustar00brianstaff000000 000000 #!start included /usr/local/perls/perl-5.14.2/lib/5.14.2/ExtUtils/MANIFEST.SKIP # Avoid version control files. \bRCS\b \bCVS\b \bSCCS\b ,v$ \B\.svn\b \B\.git\b \B\.gitignore\b \b_darcs\b \B\.cvsignore$ # Avoid VMS specific MakeMaker generated files \bDescrip.MMS$ \bDESCRIP.MMS$ \bdescrip.mms$ # Avoid Makemaker generated and utility files. \bMANIFEST\.bak \bMakefile$ \bblib/ \bMakeMaker-\d \bpm_to_blib\.ts$ \bpm_to_blib$ \bblibdirs\.ts$ # 6.18 through 6.25 generated this # Avoid Module::Build generated and utility files. \bBuild$ \b_build/ \bBuild.bat$ \bBuild.COM$ \bBUILD.COM$ \bbuild.com$ # Avoid temp and backup files. ~$ \.old$ \#$ \b\.# \.bak$ \.tmp$ \.# \.rej$ # Avoid OS-specific files/dirs # Mac OSX metadata \B\.DS_Store # Mac OSX SMB mount metadata files \B\._ # Avoid Devel::Cover and Devel::CoverX::Covered files. \bcover_db\b \bcovered\b # Avoid MYMETA files ^MYMETA\. #!end included /usr/local/perls/perl-5.14.2/lib/5.14.2/ExtUtils/MANIFEST.SKIP \.travis.yml \.releaserc \.gitignore Tie-\.* Tie-Cycle-1.221/META.json000664 000765 000024 00000002521 12654216432 015163 0ustar00brianstaff000000 000000 { "abstract" : "Cycle through a list of values via a scalar.", "author" : [ "brian d foy " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.140640", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Tie-Cycle", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : {} }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.64", "File::Spec::Functions" : "0" } }, "runtime" : { "requires" : { "Carp" : "0", "perl" : "5.008" } }, "test" : { "requires" : { "Test::More" : "0.95" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/briandfoy/tie-cycle/issues" }, "homepage" : "https://github.com/briandfoy/tie-cycle", "repository" : { "type" : "git", "url" : "https://github.com/briandfoy/tie-cycle.git", "web" : "https://github.com/briandfoy/tie-cycle" } }, "version" : "1.221" } Tie-Cycle-1.221/META.yml000664 000765 000024 00000001323 12654216430 015010 0ustar00brianstaff000000 000000 --- abstract: 'Cycle through a list of values via a scalar.' author: - 'brian d foy ' build_requires: Test::More: '0.95' configure_requires: ExtUtils::MakeMaker: '6.64' File::Spec::Functions: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.140640' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Tie-Cycle no_index: directory: - t - inc requires: Carp: '0' perl: '5.008' resources: bugtracker: https://github.com/briandfoy/tie-cycle/issues homepage: https://github.com/briandfoy/tie-cycle repository: https://github.com/briandfoy/tie-cycle.git version: '1.221' Tie-Cycle-1.221/README.pod000644 000765 000024 00000006201 12654216422 015177 0ustar00brianstaff000000 000000 =pod =encoding utf8 =head1 The Tie::Cycle module This is the I for the L Perl module. It allows you to create an array that continually cycles through its elements no matter what index you use. You're probably looking at this because you don't know where else to find what you're looking for. Read this once and you might never have to read one again for any Perl module. =head2 Documentation To read about L, look at the embedded documentation in the module itself. Inside the distribution, you can format it with L: % perldoc lib/Tie/Cycle.pm If you have already installed the module, you can specify the module name instead of the file location: % perldoc Tie::Cycle You can read the documentation and inspect the meta data on one of the CPAN web interfaces, such as L or L: =over 4 =item * L =item * L =back The standard module documentation has example uses in the SYNOPSIS section, but you can also look in the I directory (if it's there), or look at the test files in I. =head2 Installation You can install this module with a CPAN client, which will resolve and install the dependencies: % cpan Tie::Cycle % cpanm Tie::Cycle You can also install directly from the distribution directory, which will also install the dependencies: % cpan . % cpanm . You could install just this module manually: % perl Makefile.PL % make % make test % make install You probably don't want to do that unless you're fiddling with the module and only want to run the tests without installing anything. =head2 Source location The meta data, such as the source repository and bug tracker, is in I or the I files it creates. You can find that on those CPAN web interfaces, but you can also look at files directly in the source repository: =over 4 =item * L =back If you find a problem, file a ticket in the L: =over 4 =item * L =back =head2 Getting help Although I'm happy to hear from module users in private email, that's the best way for me to forget to do something. Besides the issue trackers, you can find help at L or L, both of which have many competent Perlers who can answer your question, almost in real time. They might not know the particulars of this module, but they can help you diagnose your problem. You might like to read L. =head2 Copyright and License You should have received a I file, but the license is also noted in the module files. About the only thing you can't do is pretend that you wrote code that you didn't. =head2 Good luck! Enjoy, brian d foy, bdfoy@cpan.org =cut Tie-Cycle-1.221/t/000755 000765 000024 00000000000 12654216426 014006 5ustar00brianstaff000000 000000 Tie-Cycle-1.221/xt/000755 000765 000024 00000000000 12654216426 014176 5ustar00brianstaff000000 000000 Tie-Cycle-1.221/xt/changes.t000644 000765 000024 00000000203 12654216422 015762 0ustar00brianstaff000000 000000 use Test::More; eval 'use Test::CPAN::Changes'; plan skip_all => 'Test::CPAN::Changes required for this test' if $@; changes_ok(); Tie-Cycle-1.221/t/cycle.t000644 000765 000024 00000000522 12654216422 015265 0ustar00brianstaff000000 000000 use Test::More; use Tie::Cycle; my @array = qw( A B C ); tie my $cycle, 'Tie::Cycle', \@array; foreach( 0 .. 2 ) { is( $cycle, $array[0], "Cycle is first element, iteration $_" ); is( $cycle, $array[1], "Cycle is second element, iteration $_" ); is( $cycle, $array[2], "Cycle is third element, iteration $_" ); } done_testing(); Tie-Cycle-1.221/t/load.t000644 000765 000024 00000000114 12654216422 015102 0ustar00brianstaff000000 000000 use Test::More 0.95; use_ok( 'Tie::Cycle' ) or BAILOUT(); done_testing(); Tie-Cycle-1.221/t/one.t000644 000765 000024 00000000465 12654216422 014755 0ustar00brianstaff000000 000000 use Test::More 0.95; use Tie::Cycle; my @array = qw( A ); tie my $cycle, 'Tie::Cycle', \@array; is( $cycle, $array[0], "Cycle is first element, iteration 1" ); is( $cycle, $array[0], "Cycle is first element, iteration 2" ); is( $cycle, $array[0], "Cycle is first element, iteration 3" ); done_testing(); Tie-Cycle-1.221/t/pod.t000644 000765 000024 00000000206 12654216422 014747 0ustar00brianstaff000000 000000 use Test::More 0.95; eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok(); Tie-Cycle-1.221/t/pod_coverage.t000644 000765 000024 00000000357 12654216422 016631 0ustar00brianstaff000000 000000 use Test::More 0.95; eval "use Test::Pod::Coverage"; if( $@ ) { plan skip_all => "Test::Pod::Coverage required for testing POD"; } else { pod_coverage_ok( "Tie::Cycle", { trustme => [ qr/^[A-Z_]+$/ ] } ); } done_testing(); Tie-Cycle-1.221/t/test_manifest000644 000765 000024 00000000052 12654216422 016567 0ustar00brianstaff000000 000000 load.t pod.t pod_coverage.t cycle.t one.t Tie-Cycle-1.221/lib/Tie/000755 000765 000024 00000000000 12654216426 015032 5ustar00brianstaff000000 000000 Tie-Cycle-1.221/lib/Tie/Cycle.pm000644 000765 000024 00000006400 12654216422 016423 0ustar00brianstaff000000 000000 package Tie::Cycle; use strict; our $VERSION = '1.221'; use Carp qw(carp); use constant CURSOR_COL => 0; use constant COUNT_COL => 1; use constant ITEM_COL => 2; sub TIESCALAR { my( $class, $list_ref ) = @_; my $self = bless [], $class; unless( $self->STORE( $list_ref ) ) { carp "The argument to Tie::Cycle must be an array reference"; return; } return $self; } sub FETCH { my( $self ) = @_; my $index = $self->[CURSOR_COL]++; $self->[CURSOR_COL] %= $self->_count; return $self->_item( $index ); } sub STORE { my( $self, $list_ref ) = @_; return unless ref $list_ref eq ref []; my @shallow_copy = map { $_ } @$list_ref; $self->[CURSOR_COL] = 0; $self->[COUNT_COL] = scalar @shallow_copy; $self->[ITEM_COL] = \@shallow_copy; } sub reset { $_[0]->[CURSOR_COL] = 0 } sub previous { my( $self ) = @_; my $index = $self->_cursor - 1; $self->[CURSOR_COL] %= $self->_count; return $self->_item( $index ); } sub next { my( $self ) = @_; my $index = $self->_cursor + 1; $self->[CURSOR_COL] %= $self->_count; return $self->_item( $index ); } sub _cursor { $_[0]->[CURSOR_COL] } sub _count { $_[0]->[COUNT_COL] } sub _item { my( $self, $index ) = @_; $index = defined $index ? $index : $self->_cursor; $self->[ITEM_COL][ $index ] } "Tie::Cycle"; __END__ =encoding utf8 =head1 NAME Tie::Cycle - Cycle through a list of values via a scalar. =head1 SYNOPSIS use v5.10; use Tie::Cycle; tie my $cycle, 'Tie::Cycle', [ qw( FFFFFF 000000 FFFF00 ) ]; say $cycle; # FFFFFF say $cycle; # 000000 say $cycle; # FFFF00 say $cycle; # FFFFFF back to the beginning (tied $cycle)->reset; # back to the beginning =head1 DESCRIPTION You use C to go through a list over and over again. Once you get to the end of the list, you go back to the beginning. You don't have to worry about any of this since the magic of tie does that for you. The tie takes an array reference as its third argument. The tie should succeed unless the argument is not an array reference. Previous versions required you to use an array that had more than one element (what's the pointing of looping otherwise?), but I've removed that restriction since the number of elements you want to use may change depending on the situation. During the tie, this module makes a shallow copy of the array reference. If the array reference contains references, and those references are changed after the tie, the elements of the cycle will change as well. See the included F script for an example of this effect. =head1 OBJECT METHODS You can call methods on the underlying object (which you access with C ). =over 4 =item reset Roll the iterator back to the starting position. The next access will give the first element in the list. =item previous Give the previous element. This does not affect the current position. =item next Give the next element. This does not affect the current position. You can peek at the next element if you like. =back =head1 SOURCE AVAILABILITY This module is on Github: https://github.com/briandfoy/tie-cycle =head1 AUTHOR brian d foy, C<< >> =head1 COPYRIGHT AND LICENSE Copyright © 2000-2015, brian d foy . All rights reserved. This software is available under the same terms as perl. =cut Tie-Cycle-1.221/examples/README000644 000765 000024 00000000105 12654216422 016231 0ustar00brianstaff000000 000000 See the tests in the t/ directory for examples until I add some more.