sub example { if(wantarray) { return (1,2,3); } return [1,2,3]; } my @array = example(); my $arrayref = example();