The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
package MyEnum;
use strict;

sub new {
    my ($class, @x) = @_;
    return bless [ @x ], $class;
}

sub each {
    my ($self, $cb) = @_;

    my $i = 0;
    for my $x (@$self) {
        local $_ = $x;
        $cb->($i++);
    }
}

1;