NAME
Object::Array::Plugin::Builtins
SYNOPSIS
See Object::Array.
Provides analogues to Perl's built-in array operations.
METHODS
size
length
Returns the number of elements in the array.
size
and length
are synonyms.
element
elem
print $array->elem(0);
print $array->[0];
Get a single element's value.
$array->elem(1 => "hello");
$array->[1] = "hello";
Set a single element's value.
element
and elem
are synonyms.
slice
print for $array->slice([ 0, 1, 2 ]);
print for @{$array}[0,1,2];
Get multiple values.
$array->slice([ 0, 1, 2 ] => [ qw(a b c) ]);
@{$array}[0,1,2] = qw(a b c);
Set multiple values.
elements
elems
Shortcut for all values in the array.
elements
and elems
are synonyms.
NOTE: Using methods in a for/map/etc. will not do aliasing via $_. Use array dereferencing if you need to do this, e.g.
$_++ for @{$array};
clear
Erase the array. The following all leave the array empty:
$array->size(0);
$array->clear;
@{ $array } = ();
push
pop
shift
unshift
exists
delete
splice
map
grep
join
As the builtin array operations of the same names.
Note that since map and grep are called as methods, you must use <sub { }
> (no bare blocks).