The Underbar: A Perl-adjacent maybe-podcast. Learn more

use 5.014;
use strict;
use registry 'Data::Object::Types';
our $VERSION = '2.05'; # VERSION
# BUILD
has arg1 => (
is => 'ro',
isa => 'ArrayLike',
req => 1
);
has arg2 => (
is => 'ro',
isa => 'CodeLike',
req => 1
);
has args => (
is => 'ro',
isa => 'ArrayRef[Any]',
opt => 1
);
# METHODS
sub execute {
my ($self) = @_;
my $results = [];
my ($data, $code, @args) = $self->unpack;
for (my $i = 0; $i < @$data; $i++) {
my $index = $i;
my $value = $data->[$i];
push @$results, $code->($index, @args);
}
return $results;
}
sub mapping {
return ('arg1', 'arg2', '@args');
}
1;