Object::Array - array references with accessors
Version 0.02
use Object::Array; my $array = Object::Array->new; # or $array = Object::Array->new(\@array); $array->push(1..5); print $array->shift; $_++ for grep { $_ < 4 } @{ $array }; $array->[0] = "a pony";
new
my $array = Object::Array->new; # or use existing array my $array = Object::Array->new(\@a);
Creates a new array object, either from scratch or from an existing array.
Using an existing array will mean that any changes to $array also affect the original array object. If you don't want that, copy the data first or use something like Storable's dclone.
$array
dclone
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.
print for $array->elem([ 0, 1, 2 ]); print for @{$array}[0,1,2];
Get multiple values.
$array->elem([ 0, 1, 2 ] => [ qw(a b c) ]); @{$array}[0,1,2] = qw(a b c);
Set multiple values.
element and elem are synonyms.
elements
elems
all
Shortcut for all values in the array.
elements, elems, and all 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
As the builtin array operations of the same names.
Hans Dieter Pearcey, <hdp at cpan.org>
<hdp at cpan.org>
Please report any bugs or feature requests to bug-object-array at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Object-Array. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-object-array at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Object::Array
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Object-Array
CPAN Ratings
http://cpanratings.perl.org/d/Object-Array
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Object-Array
Search CPAN
http://search.cpan.org/dist/Object-Array
Copyright 2006 Hans Dieter Pearcey, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Object::Array, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Object::Array
CPAN shell
perl -MCPAN -e shell install Object::Array
For more information on module installation, please visit the detailed CPAN module installation guide.