Array:...tional(3pm)

πŸ“¦
version 0.136 Β· 2 versions
, in ubuntu stonking

πŸ’– Array::Iterator::LegacyBiDirectional (3pm) πŸ’–

okay bestie, welcome to the legacy corner of Array::Iterator land β€” this is the section 3pm manual page for Array::Iterator::LegacyBiDirectional, and yes it's the old-school one, but she still serves. 🌸


✨ VERSION ✨

Version 0.136 β€” periodt. πŸ‘‘


🌈 SYNOPSIS 🌈

use Array::Iterator::LegacyBiDirectional;

# create an instance of the iterator
my $i = Array::Iterator::LegacyBiDirectional->new(1 .. 100);

while ($some_condition_exists) {
    # get the latest item from
    # the iterator
    my $current = $i->get_next();
    # ...
    if ($something_happens) {
        # back up the iterator
        $current = $i->get_previous();
    }
}

πŸ¦‹ DESCRIPTION πŸ¦‹

so this is the old BiDirectional code. it's literally kept around for the users who want the old way that the pointer was kept. if you wanna know more, go read RT#126034 for the full tea. πŸ«–

now, sometimes an iterator just needs to go both ways β€” forward and backward, like a main character who refuses to be linear. πŸ’… one example? token processing. when you're looping through tokens, sometimes you gotta move forward hunting for a match to a rule. and if the match fails, a bi-directional iterator can be moved back so the next rule can be tried. it's giving second chances. πŸŽ€


πŸŽ€ METHODS πŸŽ€

this is a subclass of Array::Iterator, and lowkey only the methods that got added are documented here. for everything else, refer to the Array::Iterator documentation, bestie. πŸ’œ

  • has_previous([$n]) β€” this method works much like hasNext does. it returns true (1) unless the beginning of the array has been reached, and false (0) otherwise. the optional argument has the same meaning except that it specifies the $nth previous element. πŸ“
  • previous β€” this method is much like next. it returns the previous item in the iterator, and throws an exception if it attempts to reach past the beginning of the array. dramatic? yes. necessary? also yes. 😭
  • get_previous β€” this method is much like get_next. it returns the previous item in the iterator, and returns undef if it attempts to reach past the beginning of the array. soft launch rejection. πŸ™ˆ
  • look_back([$n]) β€” this is the counterpart to peek. it returns the previous items in the iterator, but will not affect the internal counter. no touchy, just looky. πŸ‘€ the optional argument has the same meaning except that it specifies the $nth previous element. ⭐

πŸ”₯ SEE ALSO πŸ”₯

this is a subclass of Array::Iterator, so please refer to it for more documentation. she's the parent, respect her. πŸ‘‘


πŸ’– 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. 🫢


ok that's the whole page, no cap. everything's here, nothing skipped β€” go forth and iterate in both directions, queen. πŸ’…βœ¨

perl v5.40.1 Β· 2026-03-11 β€” mwah, thanks for reading, ily, bye bestie! πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from