Shawn H Corey <[email protected]> writes:

> On Mon, 18 Aug 2014 16:17:53 +0800
> Ken Peng <[email protected]> wrote:
>
>> sub myfunc {
>>   my @x=(1,2,3);
>>   return \@x;
>> }
>> 
>> # or,
>> 
>> sub myfunc {
>>   my @x=(1,2,3);
>>   return [@x];
>> }
>
> # or
>
> sub myfunc {
>   return [ 1, 2, 3 ];
> }

Is there a difference to

sub myfunc {
  return ( 1, 2, 3 );
}

?  And my understanding was/is that in

sub myfunc {
  my @x=(1,2,3);
  return \@x;
}

a reference would be returned to an array that ceases to exist when the
function returning it has finished.  At the point the function returns
to, there isn't anything left the reference could refer to.

Or is there?


-- 
Knowledge is volatile and fluid.  Software is power.

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to