Acme-Array-MaxSize

 view release on metacpan or  search on metacpan

lib/Acme/Array/MaxSize.pm  view on Meta::CPAN


use parent 'Tie::Array';
use Carp;

my %max_size;
my $last_index = sub { $max_size{+shift} - 1 };


sub TIEARRAY {
    my ($class, $max_size) = @_;
    my $self = bless [], $class;
    $max_size{$self} = $max_size;
    return $self
}

sub STORE {
    my ($self, $index, $value) = @_;
    if ($index > $self->$last_index) {
        carp 'Array too long';
        return
    }



( run in 0.369 second using v1.01-cache-2.11-cpan-de7293f3b23 )