use warnings; use strict; package Test; sub new { my $class = shift; my $self = { _DataMember0 => shift, _Array0 => shift, }; bless $self, $class; } sub get__Array0{ my $self = shift; if (wantarray){ # caller wants a list (dereference the ref before return) return @{ $self->{_Array0} }; } else { # caller wants an array reference return $self->{_Array0}; } } package main; my $aref = [1, 2, 3]; my $test = Test->new(1, $aref); # get it as a list my @array = $test->get__Array0(); # parens not needed, only used for clarity # get an aref instead my $array_reference = $test->get__Array0(); print "$_\n" for @array; print "$array_reference->[0]\n";