return the list content

2014-08-18 Thread Ken Peng
Hello, 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? Thanks. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands

Re: return the list content

2014-08-18 Thread Paul Johnson
On Mon, Aug 18, 2014 at 04:17:53PM +0800, Ken Peng wrote: > Hello, > > 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? F

Re: return the list content

2014-08-18 Thread Shawn H Corey
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 ]; } -- Don't stop where the ink does. Shawn -- To unsubscribe, e-mail:

Re: return the list content

2014-08-18 Thread John SJ Anderson
On Mon, Aug 18, 2014 at 1:38 AM, Paul Johnson wrote: > On Mon, Aug 18, 2014 at 04:17:53PM +0800, Ken Peng wrote: >> which one is the better way to return the list content? And if the >> method is an instance method? > > Functionally, the two are identical. The first is returning a reference > to