Array:...ircular(3pm)

Array::Iterator::Circular πŸ’« β€” the iterator that never says goodbye

okay bestie, so this is the docs for Array::Iterator::Circular, which lives in the User Contributed Perl Documentation corner of the manual. It's tiny, it's iconic, and it does exactly one unhinged little thing: it loops forever. πŸ¦‹


✨ VERSION ✨

Version 0.136 πŸ’…


🌸 SYNOPSIS 🌸

  use Array::Iterator::Circular;

  # create an instance with a
  # small array
  my $color_iterator = Array::Iterator::Circular->new(qw(red green blue orange));

  # this is a large list of
  # arbitrary items
  my @long_list_of_items = ( ... );

  # as we loop through the items ...
  foreach my $item (@long_list_of_items) {
      # we assign color from our color
      # iterator, which will keep dispensing
      # as it loops through its set
      $item->set_color($color_iterator->next());
  }

  # tell us how many times the set
  # was looped through
  print $color_iterator->get_loop_count();

like… look at her. red, green, blue, orange, and then? red again. no cap. 🌈


πŸŽ€ DESCRIPTION πŸŽ€

This iterator will loop continuously as long as next or get_next is called. The has_next method will always return true (1), since the list will always loop back.

It's giving ✨infinite content✨, and it is so useful when you need a list to repeat itself but you don't want to (or simply don't care to) know that it's doing so. lowkey the whole point. periodt. πŸ’–


πŸ’… METHODS πŸ’…

This is a subclass of Array::Iterator, so only the methods that got added or changed get documented down here β€” for everything else, go read the Array::Iterator docs, bestie. 🫢

  • has_next β€” since we endlessly loop, this will always return true (1). Like, always. It's never not true. πŸ’€
  • next β€” hands you the next item in the array, and once it hits the end of the array? it loops right back to the beginning again. the circle of life fr fr. πŸ”₯
  • get_next β€” this one is now defined in terms of next. Since neither of them ever stops dispensing items, there's no need to tell them apart anymore. twins. πŸ‘‘
  • is_start β€” if at any point during your looping you're like "wait, did I come back to the start of my list?", you just ask this method. vibe check for the beginning. 🌸
  • is_end β€” same energy, other end: if at any point during your looping you wanna know whether you've gotten to the end of your list, you ask this method. ✨
  • get_loop_count β€” tells you how many times the iterator has looped back to its start. the receipts. the score. print it and feel something. 😭

πŸ’œ SEE ALSO πŸ’œ

This is a subclass of Array::Iterator, so please refer to that one for more documentation. it's literally the parent. show some respect. πŸ™ˆ


🧚 MAINTAINER 🧚

Nigel Horne, "<njh at nigelhorne.com>"

2025-2026


⭐ ORIGINAL AUTHOR ⭐

stevan little, <stevan@iinteractive.com>


Copyright 2004 by Infinity Interactive, Inc.

<http://www.iinteractive.com>

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

so basically: use it, remix it, ship it β€” same terms as Perl itself. understood? πŸ’–

okay that's the whole page, bestie. πŸŽ€ this fine piece of documentation was served up by perl v5.40.1 on 2026-03-11, and that's the <rainbow>Array::Iterator::Circular(3pm)</rainbow> moment β€” looping back around to the start, forever and ever, exactly like the module intended. slay. πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from