my $a = MyArray->new; $a->testfunc('foo'); $a->testfunc('bar'); $a->testfunc('baz'); print "$_\n" for $a->list; package MyArray; sub new { bless [], shift } sub testfunc { push @{ $_[0] }, $_[1] } sub list { @{ $_[0] } } 1;