Appendix: Source Code

Tie::Array::Bounded

package Tie::Array::Bounded;use strict;use warnings;use Carp;use base qw(Tie::Array);our $VERSION = '0.01';sub TIEARRAY{  my ($class, %arg) = @_;  my ($upper, $lower) = delete @arg{qw(upper lower)};  croak "Illegal arguments in tie" if %arg;  $lower ||= 0;  croak "No upper bound for array" unless $upper;  /\D/ and croak "Array bound must be integer"    for ($upper, $lower);  croak "Upper bound < lower bound" if $upper < $lower;  return bless { upper => $upper,                 lower => $lower,                 array => []               }, $class;}sub _bound_check{  my ($self, $index) = @_;  my ($upper, $lower) = @{$self}{qw(upper lower)};  croak "Index $index out of range ...

Get Perl Medic: Transforming Legacy Code now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.