Re: return the list content

2014-09-08 Thread Ken Peng
Since this is a shadow copy, I don't think the first array will be deleted completely. Isn't it? The second option creates the same array and populates it, but then copies it to another anonymous array, deletes the first array, and returns a reference to the copy. -- To unsubscribe, e-mail:

Re: return the list content

2014-09-08 Thread Rob Dixon
On 18/08/2014 09:17, Ken Peng wrote: sub myfunc { my @x=(1,2,3); return \@x; } # or, sub myfunc { my @x=(1,2,3); return [@x]; } which one is the better way to return the list content? And if the method is an instance method? The first version of the subroutine is the best choice

Re: returning arrays (was: Re: return the list content)

2014-09-08 Thread Shawn H Corey
On Tue, 09 Sep 2014 00:13:13 +0200 lee wrote: > Shawn H Corey writes: > > > On Mon, 18 Aug 2014 16:17:53 +0800 > > Ken Peng wrote: > > > >> sub myfunc { > >> my @x=(1,2,3); > >> return \@x; > >> } > >> > >> # or, > >> > >> sub myfunc { > >> my @x=(1,2,3); > >> return [@x]; > >> } > >

Re: returning arrays (was: Re: return the list content)

2014-09-08 Thread Jim Gibson
On Sep 8, 2014, at 3:13 PM, lee wrote: > Shawn H Corey writes: > >> On Mon, 18 Aug 2014 16:17:53 +0800 >> Ken Peng wrote: >> >>> sub myfunc { >>> my @x=(1,2,3); >>> return \@x; >>> } >>> >>> # or, >>> >>> sub myfunc { >>> my @x=(1,2,3); >>> return [@x]; >>> } >> >> # or >> >> sub myfu

returning arrays (was: Re: return the list content)

2014-09-08 Thread lee
Shawn H Corey writes: > On Mon, 18 Aug 2014 16:17:53 +0800 > Ken Peng 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 su

Re: async, non blocking tcp server

2014-09-08 Thread lee
Chris Knipe writes: > This is an actual example of a communication stream between a client > and the perl server, the socket is already established, and > communication is flowing between the two parties. [C] indicates what > the client is sending to the server, and [S] indicates the responses >