#!/usr/bin/perl -w use strict; { package FixedArrayOfScalarRefs; use Carp qw( croak ); sub TIEARRAY { my ( $class, @refs ) = @_; my $self = [@refs]; bless $self, $class; return $self; } sub FETCH { my ( $self, $index ) = @_; if ( not ref $self->[$index] ) { croak "Array index $index out-of-bounds"; } my $value = ${ $self->[$index] }; return $value; } sub STORE { my ( $self, $index, $value ) = @_; if ( not ref $self->[$index] ) { croak "Array index $index out-of-bounds"; } ${ $self->[$index] } = $value; } sub FETCHSIZE { my ($self) = @_; return scalar @$self; } }