use strict; use warnings; package Foo; sub new { my $class = shift; my $self = { testarray => [] }; bless $self, $class; return $self; } sub testfunc { my $self = shift; my $var = shift; push( @{$self->{testarray}}, $var ); return 1; } sub list { my $self = shift; return @{$self->{testarray}}; } package main; my $foo = new Foo; $foo->testfunc("a"); $foo->testfunc("b"); print $foo->list, "\n";