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

NAME

Object::Array - array references with accessors

VERSION

Version 0.02

SYNOPSIS

  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";

METHODS

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.

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.

AUTHOR

Hans Dieter Pearcey, <hdp at cpan.org>

BUGS

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.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Object::Array

You can also look for information at:

ACKNOWLEDGEMENTS

COPYRIGHT & LICENSE

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.