package Test; use Tie::Array; use Exporter(); @ISA = qw( Exporter Tie::StdArray ); sub new { my $class = shift; my @self; tie @self, $class; bless \@self, $class; } sub test { print "hello world\n"; } sub test2 { my $self = shift; print $self->{ test }, "\n"; # LINE 22 } sub TIEARRAY { my $class = shift; return bless { test => [] }, $class; } sub STORE { my $class = shift; my $index = shift; my $value = shift; $self->{ test }->[ $index ] = $value; } sub FETCH { my $class = shift; my $index = shift; return $self->{ test }->[ $index ]; } my $test = new Test(); $test->[0] = "test"; $test->test(); $test->test2();