Tie::Array::Lazier - Lazier than Tie::Array::Lazy
$Id: Lazier.pm,v 0.2 2012/08/09 19:07:27 dankogai Exp $
use Tie::Array::Laier; # 0..Inf tie my @a, 'Tie::Array::Laier', [], sub{ $_[1] }; $a[3] = 'three'; # $self->array is [undef, undef, undef, 'three'] print "$_\n" for @a; # 0, 1, 2, 'three', 4 ...
Tie::Array::Lazier is a child class of Tie::Array::Lazy that behaves a lot like its parent except for one thing; It is even lazier.
Instead of filling elements up to $index, Tie::Array::Lazier It calls $self->maker when $self->array->[$index] is undef. Therefore you cannot store undef to the tied array.
$index
$self->maker
$self->array->[$index]
None.
Same as Tie::Array::Lazy.
While $_[0]->index is identical to $_[1] in Tie::Array::Lazy>, these values may disagree in Tie::Array::Lazier Whenever you need the index, use $_[1].
$_[0]->index
$_[1]
# 0..Inf tie my @a, 'Tie::Array::Lazier', [], sub{ $_[0]->index }; # wrong! tie my @a, 'Tie::Array::Lazier', [], sub{ $_[1] }; # right!
You can still use $_[0]->index to find how many elements the internal array holds.
Dan Kogai, <dankogai at dan.co.jp>
<dankogai at dan.co.jp>
See Tie::Array::Lazy.
Copyright 2007 Dan Kogai, 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 Tie::Array::Lazy, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tie::Array::Lazy
CPAN shell
perl -MCPAN -e shell install Tie::Array::Lazy
For more information on module installation, please visit the detailed CPAN module installation guide.