You can use Tie::Cycle under the same terms as Perl itself.