Acme-Array-MaxSize
view release on metacpan or search on metacpan
lib/Acme/Array/MaxSize.pm view on Meta::CPAN
use Acme::Array::MaxSize;
tie my @short, 'Acme::Array::MaxSize', 3;
@short = (1 .. 10);
print "@short"; # 1 2 3
=head1 DETAILS
When adding new elements, if the maximal size is reached, all other
elements are thrown away.
tie my @short, 'Acme::Array::MaxSize', 3;
@short = ('a');
push @short, 'b' .. 'h';
print "@short"; # a b c
Inserting elements at the B<very beginning> behaves differently,
though. Each C<unshift> or C<splice> would insert the maximal possible
number of elements B<at the end> of the inserted list:
( run in 0.291 second using v1.01-cache-2.11-cpan-496ff517765 )