##
sub foo { return (0,1); }
my $aref = [foo()];
####
sub foo {
my @rv = (0,1);
return wantarray() ? @rv : \@rv;
}
my $aref = [foo()]; # wantarray() will be true, so the entire list gets passed back and then the square braces create and populate an array ref.
my $aref2 = foo(); # wantarray() will be false, so inside the subroutine we return a reference to the array.