Object-Array
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Object/Array.pm view on Meta::CPAN
Currently, these array objects only contain copies of the
original values. In the future, they will retain references
to the original object, and this sort of thing will be possible:
$arr->grep(sub { defined })->[-1]++;
=head1 METHODS
=head2 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 C<<
$array >> also affect the original array object. If you
don't want that, copy the data first or use something like
Storable's C<< dclone >>.
=head2 isa
Overridden to respond to 'ARRAY'.
=head2 ref
Returns a reference to the underlying array.
=cut
my %real;
sub _addr { Scalar::Util::refaddr($_[0]) }
sub _real { $real{shift->_addr} }
*ref = \&_real;
sub _array {
my ($self, @values) = @_;
return wantarray ? @values : ref($self)->new(\@values);
}
# for exporting
sub _array_generator {
my ($class) = @_;
return sub { $class->new(@_) };
}
use overload (
q(@{}) => 'ref',
fallback => 1,
);
sub new {
my $class = shift;
my $real = shift || [];
my $self = bless \$real => $class;
$real{$self->_addr} = $real;
return $self;
}
sub isa {
my ($class, $type) = @_;
return 1 if $type eq 'ARRAY';
return $class->SUPER::isa($type);
}
=head1 SEE ALSO
L<Object::Array::Plugin::Builtins>
L<Object::Array::Plugin::ListMoreUtils>
=head1 AUTHOR
Hans Dieter Pearcey, C<< <hdp at cpan.org> >>
=head1 BUGS
Please report any bugs or feature requests to
C<bug-object-array at rt.cpan.org>, or through the web interface at
L<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.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Object::Array
You can also look for information at:
=over 4
=item * AnnoCPAN: Annotated CPAN documentation
L<http://annocpan.org/dist/Object-Array>
=item * CPAN Ratings
L<http://cpanratings.perl.org/d/Object-Array>
=item * RT: CPAN's request tracker
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Object-Array>
=item * Search CPAN
L<http://search.cpan.org/dist/Object-Array>
=back
=head1 ACKNOWLEDGEMENTS
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.082 second using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )